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.
