On Wed, 21 Oct 2009 17:13:48 -0400, Bartosz Milewski
<bartosz-nos...@relisoft.com> wrote:
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.
IIRC, Conditions should be able to use the in-object mutex. However, I
think you still need a core.sync.Mutex object. I think the way it works
is you initialize the Mutex with an object, and it inserts itself as the
in-object mutex (hopefully before the on-demand mutex is created).
So indirectly, you can do:
new Condition(new Mutex(this));
Kinda odd, I agree... This should probably be shortcutted. Sean?
-Steve