Suggestion for Condition variables
Sean Kelly
sean at f4.ca
Mon Feb 27 00:53:41 PST 2006
Graham St Jack wrote:
> Here is a suggestion for an extension to D to handle pthread-like
> condition variables in a way that fits neatly with the "synchronized"
> keyword.
>
> I use threads a lot, and quite often find that I need conditions, but
> even though all the functionality is there in the locks library, it is
> galling that I can't use the same mutex as the "synchronized" keyword.
>
> The alternatives seem to be to:
> * Eliminate or ignore the synchronized keyword and use a library all the
> time.
> * Make the language "aware" of the library, and provide a way of getting
> an object's mutex.
> * Add some more keywords to handle conditions directly.
I've been thinking about this as well, and I think it helps that the
monitor location is already specified in the ABI. This should allow
library use of monitors whether there's any official language support or
not.
> My suggestion is for the last, because I like synchronized, and because
> I don't like making the language aware of the libraries.
>
>
> So, the suggestion is to add:
>
> * A "condition" keyword that behaves for the most part just like a bool
> data type, but is actually a condition variable.
Personally, I'd be happy with library code for this, so long as it could
use the built-in monitors. I'd also like a bit more flexibility with
how locks are obtained and such, but perhaps this is better left for later.
Sean
More information about the Digitalmars-d
mailing list