[dmd-concurrency] shared arrays

Steve Schveighoffer schveiguy at yahoo.com
Thu Jan 14 11:32:40 PST 2010


----- Original Message ----

> From: Andrei Alexandrescu <andrei at erdani.com>
> 
> (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).

What about shared(T)[] where T.sizeof >= 2*(size_t.sizeof) ?  If copying an array reference is unusable, then why is copying large array elements usable?  This whole point has confused me...

Should the runtime throw an exception when asked to copy such arrays?

-Steve



      


More information about the dmd-concurrency mailing list