[Issue 21232] std.parallelism.parallel reuses thread, leading to stale static data

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 10 01:05:06 UTC 2020


--- Comment #2 from Mathias LANG <pro.mathias.lang at gmail.com> ---
> Pardon me, but isn't this to be expected? Creating a thread per iteration would be an absolutely inacceptable overhead in many cases.

It might be unacceptable performance-wise, but I think violating the
type-system like this is even less acceptable. `std.parallelism` (and
`std.concurrency`) do that on multiple occasions, by not requiring a `shared`
delegate and executing things in threads "sometimes".

D2 was designed to have a strong distinction between data that is used by
multiple threads and data that isn't, with the assumption that the latter is
the most common case. `parallel` is just trampling all over this.


More information about the Digitalmars-d-bugs mailing list