Proposal: adding condition variable to object monitors

Sean Kelly sean at invisibleduck.org
Fri Mar 20 09:00:22 PDT 2009


Graham St Jack wrote:
>>>> 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!

It was meant to be in the last D2 release and something happened with 
the script that assembles the zipfile.  I'll make double sure it's in 
this release.



More information about the Digitalmars-d mailing list