On Jul 29, 2013, at 10:07 AM, lindenk <ztaticn...@gmail.com> 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 be possible?

It sounds like you're maybe doing socket IO?  In those cases, you can open a 
pipe for signaling.  select() on whatever other socket plus the read end of the 
pipe, and if you want to break out of the blocking select() call, write a byte 
to the pipe.  Ultimately, std.concurrency should get some socket integration so 
data can arrive as messages, but that will never be as efficient as the 
approach I've described.

> Process p = new Process();
> p.doTask(p.func()); //create new thread and start function
> 
> // do stuff until this needs to exit
> 
> p.stop(); // halt running function,
> p.cleanup(); // call a clean up function for func's resources
> p.kill(); // forcibly kill the thread

Forcibly killing threads tends to be a pretty bad idea if you intend to keep 
running after the thread is killed.  It can even screw up attempts at a clean 
shutdown.

Reply via email to