void foo(Tid parent) {
bool run = true;
while(run)
{
//do_some_blocking_function();
receiveTimeout(dur!"msecs"(0),
(string s){if(s == "STAHP!") run = false;}
);
}
// clean up
send(parent, "done");
}
void main()
{
auto tid = spawn(&foo, thisTid);
// do stuff / wait for some condition
send(tid, "STAHP!");
auto msg = receiveOnly!(string)();
assert(msg == "done");
}
Ah, no I mean, what if do_some_blocking_function blocks for some
indeterminate amount of time. I would like it to exit even when
it is currently blocking (as it could be unpredictable when it
will stop blocking).