Re: Async messages to a thread.

2013-07-29 Thread John Colvin
On Monday, 29 July 2013 at 16:19:03 UTC, lindenk wrote: 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

Re: Async messages to a thread.

2013-07-29 Thread lindenk
On Monday, 29 July 2013 at 17:26:55 UTC, Sean Kelly wrote: On Jul 29, 2013, at 10:07 AM, lindenk wrote: After a bit more research it looks like everyone else uses - while(checkIfRunning()) { // block with timeout } which leads me to believe this might not be possible or standard. Althou

Re: Async messages to a thread.

2013-07-29 Thread Sean Kelly
On Jul 29, 2013, at 10:07 AM, lindenk wrote: > After a bit more research it looks like everyone else uses - > > while(checkIfRunning()) > { >// block with timeout > } > > which leads me to believe this might not be possible or standard. Although, > should something along the lines of this

Re: Async messages to a thread.

2013-07-29 Thread Sean Kelly
On Jul 29, 2013, at 8:28 AM, lindenk wrote: > > 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). Execute the blocking function

Re: Async messages to a thread.

2013-07-29 Thread lindenk
After a bit more research it looks like everyone else uses - while(checkIfRunning()) { // block with timeout } which leads me to believe this might not be possible or standard. Although, should something along the lines of this be possible? Process p = new Process(); p.doTask(p.func()); /

Re: Async messages to a thread.

2013-07-29 Thread lindenk
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 = spa

Re: Async messages to a thread.

2013-07-29 Thread John Colvin
On Monday, 29 July 2013 at 15:28:45 UTC, lindenk wrote: Hello! This is partially a general question as I don't know what this is called or if it exists. Say for example I want to do something like the following - import std.concurrency; void main() { void foo() { try {