On 6/6/11, Steven Schveighoffer <schvei...@yahoo.com> wrote:
> Then, you have a function that sets the bool and signals the condition:
>
> void endProgram()
> {
>     synchronized(mutex)
>     {
>        if(engineActive)
>        {
>            engineActive = false;
>            cond.notifyAll();
>        }
>     }
> }

Interesting, thanks. There's some WinAPI functions like
WaitForMultipleObjects, I've read about them too.

Other than that, the while loop will go away and be replaced with some
kind of front-end for the user (e.g. GUI), while the background thread
crunches some numbers. The background thread should be able to signal
if something went wrong. Throwing exceptions from the work thread is
off limits, because they don't propagate to the foreground thread, so
I'm left with either using some kind of global boolean or I'd use
std.concurrency.send() to signal that something went wrong.

Reply via email to