[dmd-concurrency] shared arrays

Sean Kelly sean at invisibleduck.org
Thu Jan 14 07:26:06 PST 2010


On Jan 14, 2010, at 5:04 AM, Steve Schveighoffer wrote:

> ----- Original Message ----
> 
>> From: Michel Fortin <michel.fortin at michelf.com>
>> 
>> Le 2010-01-14 à 7:10, Steve Schveighoffer a écrit :
>> 
>>> 
>>> What happens in cases like this:
>>> 
>>> shared(S)[] arr3;
>>> arr3[] = arr2[];
>>> 
>>> any ideas of how this can be resolved?  Should shared arrays enjoy all the 
>> operations that normal arrays have?
>> 
>> Well, you need a lock.
> 
> Whatever locks that must be taken must also be taken any time an array is accessed.
> 
> For instance you'd need to take the same lock when doing:
> 
> arr2[3].x = 5;
> 
> I don't think this is a workable solution.

This isn't bad for indexes ops, but taking the address of a shared array element is a huge problem, since information about the underlying array is lost.  This makes C-style array operations totally unfeasible for shared arrays, and this is when the data is simply shared, the atomic ops were only needed when the ref itself was shared.  Darnit.


More information about the dmd-concurrency mailing list