associative array with Parallel
jfondren
julian.fondren at gmail.com
Thu Jul 22 05:53:01 UTC 2021
On Thursday, 22 July 2021 at 05:46:25 UTC, seany wrote:
> But what about this :
>
> int [ string ] ii;
> ii.length = somearray.length;
> foreach(i,dummy; parallel(somearray)) {
> string j = generateUniqueString(i);
> ii[j] ~= somefunc(dummy);
> }
>
>
> Is this also guaranteed thread safe?
No. Consider
https://programming.guide/hash-tables-open-vs-closed-addressing.html
In the open-addressing case, one thread may be searching the
backing array while another thread is modifying it. In the
closed-addressing case, one thread may be modifying a linked list
while another thread is searching it.
More information about the Digitalmars-d-learn
mailing list