I'm using the boost::thread library (V1.44) to support threads in my C++ project.
The user needs to be able to pause the execution of a test loop, that's running in its own thread, for an unlimited amount of time and be able to resume it whenever he pleases.
Under Windows I solved it like this
bool ContintueLoop(){
if(testLoopPaused){ //testLoopPaused can be set by the user via GUI elements
try{
boost::this_thread::interruptible_wait( 2147483648 ); //that's very ugly,
// somebody knows the right way to pause it for a unlimited time?
return true;
}
catch( boost::thread_interrupted& e ){ //when the user selects resume the
// the thread is interrupted and continues from here
testLoopPaused = false;
return true;
}
if( ... ) //test for other flags like endTestLoop etc.
....
}
This works without any problems, even though it would be nice to know the correct value for an unlimited interruption.
I started to implement a linux version of my program, but I ran into the problem that I get the compiler error
error:
interruptible_wait
is not a member ofboost::this_thread
Question: What's a good way to pause a boost::thread for an unlimited time (until the user decides to resume it)
Thank you very much