Proposal: adding condition variable to object monitors
Graham St Jack
graham.stjack at internode.on.net
Thu Mar 19 23:42:08 PDT 2009
>>>
>>> class C
>>> {
>>> Mutex m;
>>> Condition c;
>>>
>>> this()
>>> {
>>> // make m this object's monitor
>>> m = new Mutex( this );
>>> c = new Condition( m );
>>> }
>>>
>>> synchronized void foo()
>>> {
>>> // m is locked
>>> c.notify();
>>> }
>>> }
>>
I like this approach, and agree that it is very useful to be able to have
more than one condition share the same mutex.
I don't mind the handraulic creation of the mutex and condition when you
are using a condition, because of the added flexibility and the fact that
it doesn't come up much.
Being able to use the Object's monitor for the mutex is really good too.
Please release it soon!
More information about the Digitalmars-d
mailing list