Expose underlying Mutex in Condition?
Sean Kelly
sean at invisibleduck.org
Tue Jul 19 06:04:05 PDT 2011
Steven Schveighoffer Wrote:
>
> Hm... actually, we could do away with the mutex, and have the condition's
> monitor be the mutex:
>
> auto fooCondition = new Condition(); // automatically generates new mutex.
>
> synchronized(fooCondition)
> {
> fooCondition.notifyAll();
> // or
> while(!someCondition)
> fooCondition.wait();
> }
>
> We could keep the current behavior (accept a mutex), but still have the
> mutex passed in be used as the monitor for the condition. Actually, can a
> mutex be used as the monitor for more than one object? Because it's
> possible multiple conditions can use the same mutex, so it's a legitimate
> concern.
>
> Sean? I think this is a really good idea...
Seems easy enough. Why not.
More information about the Digitalmars-d
mailing list