Condition Mutexes

Bartosz Milewski bartosz-nospam at relisoft.com
Wed Oct 21 14:13:48 PDT 2009


dsimcha Wrote:

> Bartosz, since you're a threading guru, could you please write a simple test
> program using core.sync.condition and see if it works, and if not either file a
> bug report or let me know?

Conditions were implemented by Sean Kelly, so he's the guru. The file condition.d in core.sync has unit tests, which presumably still run (although I don't know if anybody still runs unit tests in druntime). 

If using conditions in D is harder than in Java, than we should rethink their implementation. Every D object has a built-in mutex. Conditon variables should be able to work with this mutex and with synchronized sections out of the box. The most common case should be the easiest. The fact that you are having all those technical problems proves my point. 

As for non-technical problems, rewrite your test so that you wait on a condition in main and let the new thread do the signalling. That way they won't be able to miss each other, as they currently do.



More information about the Digitalmars-d mailing list