This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: waiting for more than one cond in pThread question
Keith Willis wrote:
> On Tue, 2 Apr 2002 13:27:25 +0200, "Nir Nizry"
> <email@example.com> wrote:
> >I probably wasn't much understood. What I'm trying is wait for one OR more.
> >I want to "be release" when either one OR more of the conds/events are set
> >and I have to know which one was set.
> OK, how about you associate one mutex/condvar with the _set_ of
> predicate conditions, and do something like:
> while (predicate_one == FALSE && predicate_two == FALSE)
> pthread_cond_wait(&condvar, &mutex);
> if (predicate_one == TRUE)
> else if (predicate_two == TRUE)
... except you need to unlock the mutex after you've finished
using or copying the predicate values locally, otherwise
you've got a race condition.