Can somebody explain to me, why the example below is not working
in a way I'm expecting it to work?
My example is a little bit longer this time, however the half of
it is taken from
static S s;
auto ref s()
D.s.data.length = 4;
auto childTid = spawn(&runner, thisTid);
static void runner(Tid ownerTid)
import core.thread : Thread;
// Send a message back to the owner thread
// indicating success.
The idea is:
the model is something that I can declare deliberately in the
application. And, I assumed that if it is (globally) shared, then
so are all compartments of it, even if they are not explicitly
part of the model.
Some problems arose:
1. Obviously, this is not the case, as the output is different,
depending on the thread I start the model function.
2. If I declare the model object inside the main, the compiler
aborts with the message "Aliases to mutable thread-local data not
3. If I mark the S instance as shared, it works. But I didn't
intend to do this... Is this really how it meant to be?
As I'm writing the model object as well as all of its
compartments, I can do almost everything... but what I to avoid
is to declare the instances of compartments inside the model:
They are stored locally to their modules and the single elements
of them have to know about the compound objects, like with the D
and S structs shown.