Hi Rush
On Jun 13, 2010, at 11:43 AM, Conoscenza Silente wrote:Hi All
I am playing with boost::thread and it is not clear how thread::interrupt actually works.
If I understood clearly the thread will be interrupted the next time it enters one of the predefined interruption points; since thread::join is one interruption point, after I call tr.interrupt() I am expected that the thread will throw a boost::thread_interrupted exception once I call tr.join() right? .
I believe that if your thread had started a second thread and was waiting on thread::join() for the second level thread to finish, and if you called thread::interrupt on the first thread, then you would see the exception.i.e.void levelTwo (void){while (true){;}}void levelOne (void){try{boost::thread t2 (levelTwo);t2.join();}catch (const boost::thread_interrupted& ex ){std::cout << "levelOne was interrupted" << std::endl;}}int main( int argc, char** argv ){boost::thread t1( levelOne );t1.interrupt();
boost::this_thread::sleep( boost::posix_time::seconds( 3 ) );
std::cout << "calisl to INTER." << std::endl; std::cout.flush();}- Rush
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users