Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How I can wait more then one condition variable in one place?

condition wait
0
Posted

How I can wait more then one condition variable in one place?

0

Condition variables are merely devices to delay the execution of a thread. You don’t need more than one of these in order to accomplish that task. Threads that use condition variables actually wait for a predicate to become true; the evaluation of that predicate is done explicitly in the code, while holding a mutex, e.g. lock mutex … while not predicate() wait (condition, mutex ) … unlock mutex You can easily wait on an array of predicates, provided that they are protected by the same mutex. Simply loop over all of them, and if they are all false, wait on the condition. If some of them are true, the perform the associated servicing. >I need pthread analog for WaitForMultipleObjects (WIN32) or >DosWaitMuxWaitSem (OS2) You should not need this, unless you (or someone else) made the design mistake of allowing operating system synchronization objects to be used as an interface mechanism between program components. If two unrelated objects, say A and B, are both to generate independent

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123