Combining Unique type with concurrency module

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 14 00:14:20 PDT 2015


On Monday, 14 September 2015 at 00:11:07 UTC, Ali Çehreli wrote:
> There is a misconception. Unique guarantees that the object 
> will not be copied. It does not provide any guarantee that only 
> one thread will access the object. It is possible to write a 
> type that acquires a lock during certain operations but Unique 
> isn't that type.

By intention Unique means more than just "no copies" - it also 
means "only one reference at a single point of time" which, 
naturally, leads to implicit moving (not sharing!) between 
threads. However, AFAIK there are still ways to break that rule 
with existing Unique implementation and, of course, 
std.concurrency was never pacthed for special Unique support (it 
should).


More information about the Digitalmars-d-learn mailing list