[dmd-concurrency] shared arrays

Andrei Alexandrescu andrei at erdani.com
Thu Jan 14 11:21:36 PST 2010


(Replying to no message in particular.) I think there's a bit of a 
conflation of terms. There are two distinct types:

shared(T)[]

and

shared(T[])

The latter is often denoted as "shared T[] value;", i.e. without parens.

The former type is relatively simple: the array itself offers access to 
references of its elements, which in turn obey normal rules for 
shared(T). In particular, bulk updates like a[] = b[] are semantically 
equivalent to foreach loops, and therefore we don't need to worry about 
defining their semantics.

I think most of the discussion is centered around the latter type. The 
language does not have two-word atomic assignments and therefore 
shared(T[]) is basically unusable unless you e.g. use it as a member 
inside a class with synchronized method, in which case it becomes 
tail-shared, namely shared(T)[] (wow).


Andrei


More information about the dmd-concurrency mailing list