[dmd-concurrency] shared arrays

Steve Schveighoffer schveiguy at yahoo.com
Thu Jan 14 04:10:30 PST 2010


Having implemented the array append patch to fix stomping, and reading the dmd-concurrency debate, I realized that what I implemented is no good for shared arrays.

In fact, I wonder how shared arrays can support any array operations:

struct S
{
   int x;
   int y;
}

struct T
{
   shared int x;
   int y;
}

shared(S)[] arr;
T[] arr2;


what happens when you call arr.dup or arr ~= shared(S)(1,2)?  What about arr2?

In the current code, the type is just used to figure out the size, and the code calls memcpy to actually copy the data.  My biggest worry is arr2 because shared isn't even in the typeinfo passed, it's buried as a member.

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?

-Steve



      


More information about the dmd-concurrency mailing list