git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: "Zoltán Füzesi" <zfuzesi@eaglet.hu>
Cc: git@vger.kernel.org, msysGit Mailinglist <msysgit@googlegroups.com>
Subject: [PATCH] Windows: a minimal pthread_cond_broadcast
Date: Fri, 29 Jan 2010 23:16:03 +0100	[thread overview]
Message-ID: <201001292316.03858.j6t@kdbg.org> (raw)
In-Reply-To: <201001292102.49105.j6t@kdbg.org>

[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@kdbg.org>
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@kdbg.org>
---
 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

  reply	other threads:[~2010-01-29 22:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 10:27 threaded-grep cause msys build failure Zoltán Füzesi
2010-01-29 12:03 ` Johannes Sixt
2010-01-29 19:26   ` [RFC/PATCH] MSVC: Windows-native implementation of pthread_cond_broadcast Zoltán Füzesi
2010-01-29 20:02     ` Johannes Sixt
2010-01-29 22:16       ` Johannes Sixt [this message]
2010-01-29 23:54         ` [PATCH] Implement pthread_cond_broadcast on Windows Johannes Sixt
2010-01-30  2:28           ` Johannes Schindelin
2010-01-30  9:30             ` Johannes Sixt
2010-01-30 10:50               ` Johannes Schindelin
2010-01-29 20:13     ` [RFC/PATCH] MSVC: Windows-native implementation of pthread_cond_broadcast Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201001292316.03858.j6t@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=msysgit@googlegroups.com \
    --cc=zfuzesi@eaglet.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).