shared associative array initialization
Era Scarecrow
rtcvb32 at yahoo.com
Sun May 13 12:30:37 PDT 2012
On Sunday, 13 May 2012 at 16:25:42 UTC, japplegame wrote:
> I have no idea how to simple initialize shared associative
> array. This code compiled but causing access violation when
> running.
>
> shared uint[char] arr;
>
> shared static this() {
> // next expression seems wrong, because
> // arr is process related and ['a':1, 'b':2] is thread related
> // probably, should be implicit cast error
> arr = ['a':1, 'b':2];
> // this is okay, but too cumbersome
> arr['c'] = 3;
> arr['d'] = 4;
> }
I'm not sure, but I don't think the static this should be
shared; only the data. static this should only runs once during
program startup, otherwise you might be trying to do it per
thread which defeats the shared purpose anyways. I've tried it
but the problem remained.
If your array is immutable you won't need shared at all and it
should be available.
More information about the Digitalmars-d-learn
mailing list