C++ プロジェクトでスレッドをサポートするために、boost::thread ライブラリ (V1.44) を使用しています。
ユーザーは、独自のスレッドで実行されているテスト ループの実行を無制限に一時停止し、いつでも再開できる必要があります。
Windowsでは、このように解決しました
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.
....
}
これは問題なく機能しますが、無制限の中断の正しい値を知っていると便利です。
プログラムの Linux 版の実装を開始しましたが、コンパイラ エラーが発生するという問題に遭遇しました。
エラー:
interruptible_wait
のメンバーではありませんboost::this_thread
質問: boost::thread を無制限に (ユーザーが再開するまで) 一時停止する良い方法は何ですか?
どうもありがとうございました