Is this corrrect ? Each task searches for the same thing so when once has found the others don't need to run anymore. It looks a bit strange not to stop those who havent find the thing:

import std.concurrency, core.thread, std.random;

void task()
{
    size_t i;
    while (true)
    {
        Thread.sleep(dur!"nsecs"(rndGen.front / 100));
        ++i;
        rndGen.popFront;
        if (i == 100)
        {
            send(ownerTid, true);
            break;
        }
    }
}

void main()
{
    Tid s0 = spawn(&task);
    Tid s1 = spawn(&task);
    //...
    Tid sN = spawn(&task);
    receiveOnly!bool;
}

Reply via email to