I have an application where a long-lived "loader" thread takes messages to load data, loads that data, and then sends it back to the main thread via the standard concurrency primitives. Something like this:

void threadFunc(Tid ownerTid)
{
    while(true)
    {
        receive(
(int id, string path) { LoadThingByPath(ownerTid, id, path); }
        );
    }
}

void LoadThingByPath(Tid ownerTid, int id, string path)
{
    ret thing = MakeThing(path)
    send(ownerTid, id, thing);
}



I know I need to make thing shared, but I don't know how do it properly in this context. Casting to shared in send() works, but then I have to accept a shared Thing on the other side, process it as a shared Thing, etc. cast(Thing) doesn't appear to cast away the shared qualifier either. Does that mean ALL of the loaded data in my application needs to be shared all the time? Is there not simply a way to transfer ownership?

Reply via email to