Does anyone understand how to use "shared" types with concurrency send/receive functions?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 15 08:19:02 PDT 2017


On 8/15/17 10:42 AM, Kagamin wrote:
> https://github.com/dlang/phobos/blob/master/std/variant.d#L623
> memcpy(&store, cast(const(void*)) &rhs, rhs.sizeof);
> 
> should be ok to cast unconditionally

Agreed, the T value being copied has already been copied onto the stack, 
so it's not really shared.

However, I'm not sure about the postblit being called afterward. Does a 
postblit need to be marked shared in order to work for shared types?

I think also I understand why it's working for shared int* but not 
shared int -- IFTI automatically infers tail-modified for such things to 
cut down on instantiations. tail-modified means the head is not shared 
(which is in this case more accurate). This means the cast is not 
necessary, since you are copying unqualified data.

-Steve


More information about the Digitalmars-d-learn mailing list