TheKedge
28th August 2006, 14:15
Hello all,
gotta question:
i've started my thread, everything's great. Now I'd like to end it. Calling exit() exits the threads event loop. I assume it does so immediately. But in order to make sure that my thread really has finished, I'll need to do something like the following:
int BaseDevice::stopThread ()
{
quit();
if(wait ( interval() ))
;//ok
else{
log("stopThread() timed out", _TIMEOUT_ERROR);
//terminate(); //dangerous
}
return 0;
}
Thus I have a function that will wait until run() is finished. Question: does it work that way? That is, does wait() wait for event loop to exit (in which case the above doesn't work) or does it wait for run() to exit?
thanks
K
gotta question:
i've started my thread, everything's great. Now I'd like to end it. Calling exit() exits the threads event loop. I assume it does so immediately. But in order to make sure that my thread really has finished, I'll need to do something like the following:
int BaseDevice::stopThread ()
{
quit();
if(wait ( interval() ))
;//ok
else{
log("stopThread() timed out", _TIMEOUT_ERROR);
//terminate(); //dangerous
}
return 0;
}
Thus I have a function that will wait until run() is finished. Question: does it work that way? That is, does wait() wait for event loop to exit (in which case the above doesn't work) or does it wait for run() to exit?
thanks
K