boost::thread::interrupt()

We can interrupt a secondary thread from the thread that lauched it using the method thread::interrupt().

But the secondary thread has a few ways to come avoid the request of interrupting.

It could declare an object of type boost::this_thread::disable_interruption that marks a region where interrupts are not allowed to work as expected by the caller.

It could catch the exception that would cause its execution to be interrupted, its type is boost::thread_interrupted.

Another fact to keep in mind is that an interruption could be executed only at specific interruption point, that is where a join(), wait(), sleep(), or interruption_point() is called.

No comments:

Post a Comment