On Friday, March 09, 2018 19:33:26 WhatMeWorry via Digitalmars-d-learn wrote: > On Friday, 9 March 2018 at 10:42:47 UTC, Kagamin wrote: > > To make a struct noncopyable, add @disable this(this); to it, > > then compiler will give an error on an attempt to copy it. > > I tried the @disable this(this); but now it doesn't even compile? > > Error: template std.concurrency.spawn cannot deduce function from > argument types !()(void function(shared(EventBuffer) eB, > shared(Lock) lock), shared(EventBuffer), shared(Lock)), > candidates are: > C:\ldc2\bin\..\import\std\concurrency.d(464): > std.concurrency.spawn(F, T...)(F fn, T args) if (isSpawnable!(F, > T)) > > > Is std.concurrency a work in progress or I'm I just obtuse here? > > I've been reading Ali's book on the concurrency chapters as > inspiration, but the examples there use simple data types like > ints or bools.
Well, as Kagamin said, the compiler gives you an error if you @disable this(this); and then the code attempts to copy the type. The point was to catch when the type was copied, not make spawn work with your type. spawn requires that the types that its given be copyable. Either your type needs to be able to work if it's copied, or it needs to be a reference type (either by using a class, a pointer to a struct, or by making the struct's guts live on the heap with a member variable that's a pointer pointing to them). - Jonathan M Davis