[Cc msysgit list] On Freitag, 29. Januar 2010, Johannes Sixt wrote: > cond_broadcast is not that trivial. ... except when it can be tailor-made for a particular use-case. What do people think about this? I had implemented a full-blown pthread_cond_broadcast, taking ACE as an example, but I had doubts about its correctness. Then I noticed that we do not need a complete implementation anyway. So here we go... --- 8< --- From: Johannes Sixt <j6t@xxxxxxxx> Subject: [PATCH] Windows: a minimal pthread_cond_broadcast This is not an implementation, but more a fake of pthread_cond_broadcast. It is sufficient for the only call site in builtin-grep.c that we have at this time. It works because the threads that wake up due to this call do not call pthread_cond_wait anymore and terminate. Signed-off-by: Johannes Sixt <j6t@xxxxxxxx> --- compat/win32/pthread.c | 10 ++++++++++ compat/win32/pthread.h | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c index 631c0a4..7b5cac1 100644 --- a/compat/win32/pthread.c +++ b/compat/win32/pthread.c @@ -108,3 +108,13 @@ int pthread_cond_signal(pthread_cond_t *cond) else return 0; } + +/* + * FIXME: This is a fake implementation that is tailored for the only + * user that we currently have. + */ +int pthread_cond_broadcast(pthread_cond_t *cond) +{ + ReleaseSemaphore(cond->sema, cond->waiters, NULL); + return 0; +} diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h index b8e1bcb..7c360d5 100644 --- a/compat/win32/pthread.h +++ b/compat/win32/pthread.h @@ -37,12 +37,10 @@ typedef struct { } pthread_cond_t; extern int pthread_cond_init(pthread_cond_t *cond, const void *unused); - extern int pthread_cond_destroy(pthread_cond_t *cond); - extern int pthread_cond_wait(pthread_cond_t *cond, CRITICAL_SECTION *mutex); - extern int pthread_cond_signal(pthread_cond_t *cond); +extern int pthread_cond_broadcast(pthread_cond_t *cond); /* * Simple thread creation implementation using pthread API -- 1.6.6.264.ga6155 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html