Using of core.sync.condition.Condition

Sean Kelly sean at invisibleduck.org
Mon Oct 24 15:50:08 PDT 2011


On Oct 24, 2011, at 7:12 AM, Steven Schveighoffer wrote:
> 
> When waiting on a condition, you must have its associative mutex locked, or Bad Things could happen.  You should also have the mutex locked when signaling the condition, but I don't think that's an absolute requirement.
> 
> The key here is, waiting on a condition atomically unlocks the mutex.  If waiting on a condition was allowed without locking the mutex, potentially thread2 could miss thread1's signal, and you encounter a deadlock!

Bartosz just posted a tutorial on Mutexes and Conditions.  How timely:

http://www.corensic.com/Learn/Resources/ConcurrencyTutorialPartSeven.aspx


More information about the Digitalmars-d mailing list