Suggestion for Condition variables
Oskar Linde
oskar.lindeREM at OVEgmail.com
Mon Feb 27 07:42:08 PST 2006
Sean Kelly skrev:
> 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.
Any comments on Tommie Gannerts implementation?
http://www.digitalmars.com/d/archives/digitalmars/D/31340.html
/Oskar
More information about the Digitalmars-d
mailing list