Re: Combining Unique type with concurrency module

2015-09-15 Thread Alex via Digitalmars-d-learn
On Monday, 14 September 2015 at 08:08:35 UTC, Ali Çehreli wrote: void main() { MultiThreadedUnique!S u1 = produce(); auto childTid2 = spawn(, thisTid); u1.giveTo(childTid2); send(childTid2, cast(shared(MultiThreadedUnique!S*))); import core.thread; thread_joinAll();

Re: Combining Unique type with concurrency module

2015-09-14 Thread Alex via Digitalmars-d-learn
On Monday, 14 September 2015 at 00:11:07 UTC, Ali Çehreli wrote: On 09/13/2015 09:09 AM, Alex wrote: > I'm new to this forum so, please excuse me in advance for > asking silly questions. Before somebody else says it: There are no silly questions. :) > struct std.typecons.Unique!(S).Unique is

Re: Combining Unique type with concurrency module

2015-09-14 Thread Dicebot via Digitalmars-d-learn
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

Re: Combining Unique type with concurrency module

2015-09-14 Thread Ali Çehreli via Digitalmars-d-learn
On 09/14/2015 12:07 AM, Alex wrote: > Do you have a hint how to create such a type? The needed operation is > "onPassingTo" another thread. So the idea is to create a resource, which > is not really shared (a question of definition, I think), as it should > be accessible only from one thread at

Re: Combining Unique type with concurrency module

2015-09-14 Thread Dicebot via Digitalmars-d-learn
On Monday, 14 September 2015 at 00:11:07 UTC, Ali Çehreli wrote: send(childTid2, cast(shared(Unique!S*))); And yeah this violates the idea of Unique. Sadly, I am not aware of any way to prohibit taking address of an aggregate.

Combining Unique type with concurrency module

2015-09-13 Thread Alex via Digitalmars-d-learn
Hi everybody! I'm new to this forum so, please excuse me in advance for asking silly questions. I think I'm not the first person which wondering about this topic, but I'm trying to combine Unique type and concurrency module, getting the compiler error struct std.typecons.Unique!(S).Unique is

Re: Combining Unique type with concurrency module

2015-09-13 Thread Ali Çehreli via Digitalmars-d-learn
On 09/13/2015 09:09 AM, Alex wrote: > I'm new to this forum so, please excuse me in advance for > asking silly questions. Before somebody else says it: There are no silly questions. :) > struct std.typecons.Unique!(S).Unique is not copyable because it is > annotated with @disable I have made