Condition variables?

Kris foo at bar.com
Sat Sep 29 22:55:58 PDT 2007


That probably ought to be part of the library ... in Tango it lives in 
tango.core.sync.Condition.

Using pause() and resume() is prone to deadlock, so it's surprising that 
they exist in Phobos

- Kris


"David Brown" <dlang at davidb.org> wrote in message 
news:20070930045805.GA2735 at a64.davidb.org...
> Hopefully I'm missing something obvious here, but D and phobos seem to
> be missing any kind of condition variables.  It's really hard to do
> non-trivial thread programming without this kind of synchronization.
>
> In fact, I'm not sure how I could even go about implementing
> something, since there doesn't seem to be any way of easily accessing
> the object's monitor, which would be needed to do condition variables
> that work with 'synchronized'.
>
> I can think of other ways of doing synchronization, but not in a
> terribly efficient way:
>
>  - Use Thread's pause() and resume().  I would have to implement wait
>    queues and getting synchronization right on this would be
>    challenging.
>
>  - Use another OS mechanism such as pipes to sleep and wakeup.  This
>    is also not very efficient.
>
> I'm just kind of wondering why std.thread even exists without
> condition variables, since it really isn't useful for all that much,
> by itself, and doesn't seem to even have the needed hooks to implement
> any other mechanism.
>
> David Brown 





More information about the Digitalmars-d mailing list