How to destroy a shared struct.

Marco Leise Marco.Leise at gmx.de
Sun Jan 26 09:15:16 PST 2014


Since shared hasn't change much in the last years, I assume it
is somewhat accepted in its current state. My understanding is
that if something cannot be attributed to a single thread, it
is "shared". So far so good.
Now I wrote an object pool struct with two properties: it can
be used by multiple threads during its lifetime and this(this)
is disabled. Logically the struct is both created and
destroyed while only the creator thread (which holds the data)
has access to it and there is no two ways about it. An
object can only be destroyed when it is no longer shared.

Yet the D compiler asks for a shared ~this(). This sounds as
if it asks me to commit a logical error. So the question is,
how do I define a shared struct without a shared ~this() which
would be broken by definition?

-- 
Marco



More information about the Digitalmars-d-learn mailing list