What classification should shared objects in qeued thread pools have?
IGotD-
nise at nise.com
Thu Oct 1 00:13:41 UTC 2020
On Thursday, 1 October 2020 at 00:00:06 UTC, mw wrote:
>
>
> I think using `shared` is the D's encouraged way.
>
> If there is a better way do this in D, I'd want to know it too.
I think that the shared in shared structs should not be
transitive to members of the struct. The compiler should not
enforce this as we don't really know what the programmer will do
inside the struct to ensure the thread safety.
For example completely lockless algorithms can often be a
combination of atomic operations and also non-atomic operations
on data members.
I originally thought that DIP 1024 only applied for integer types
alone (not inside structs). I don't really understand the
rationale why a shared struct should all have atomic integers, it
doesn't make any sense.
More information about the Digitalmars-d-learn
mailing list