Concurrency Confusion

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 4 03:37:37 PDT 2015


On Tuesday, 4 August 2015 at 10:29:57 UTC, 岩倉 澪 wrote:
> On Tuesday, 4 August 2015 at 08:35:10 UTC, Dicebot wrote:
>>     auto output = receiveOnly!(immutable(Bar)[]);
>
> Won't message passing like this result in an expensive copy, or 
> does the cast to immutable via assumeUnique avoid that?

immutable data is implicitly shared and doesn't need to be 
duplicated - as it won't ever be modified, it is perfectly fine 
to do concurrent reads for that from multiple references.

std.concurrency does by-value message passing (in this case just 
ptr+length), it never deep copies automatically


More information about the Digitalmars-d-learn mailing list