[dmd-concurrency] synchronized, shared, and regular methods inside the same class

Andrei Alexandrescu andrei at erdani.com
Tue Jan 5 18:37:40 PST 2010


Michel Fortin wrote:
> Le 2010-01-05 à 18:31, Álvaro Castro-Castilla a écrit :
> 
>> Is there a way that to make this eventually generalizable to any 
>> operation or groups of operations that should be performed
>> atomically?
>> 
>> something like:
>> 
>> atomic { ++x; }
>> 
>> or even
>> 
>> atomic ++x; atomic(++)x;
> 
> I proposed this earlier:
> 
> ++atomic(y)
> 
> The idea is to create a function template "atomic" that would return
> a temporary struct. All operators defined for that struct would
> translate to atomic operations done on y, or memory barriers for read
> and writes.

I agree with Sean's assessment. About defining atomic(y) and the 
associated template Atomic(T), I thought some more and it looks like a 
worthwhile library addition.

Andrei


More information about the dmd-concurrency mailing list