[dmd-concurrency] Defining shared delegates

Andrei Alexandrescu andrei at erdani.com
Tue Jan 19 14:37:53 PST 2010


Michel Fortin wrote:
> Le 2010-01-19 à 15:18, Andrei Alexandrescu a écrit :
> 
>> Michel Fortin wrote:
>>> - If the data carried by the delegate is thread-local, in whole or in part,   then the delegate is thread-local.
>> I haven't thought much about shared delegates, but on the face of it this doesn't work. A delegate may increment an ostensibly thread-local variable and return it. Then, the delegate may be passed to several threads. Race ensues.
> 
> Are you reading things in reverse?
> 
> What you quoted says that if the delegate references a thread-local variable it can't be shared. If it can't be shared it can't be sent to other threads.

I guess I'm misunderstanding what's going on.

Andrei


More information about the dmd-concurrency mailing list