Boost Thread Cancelling

boost-thread, c++

Solution

They don't support cancel, which is a good thing since it can cause all manner of subtle problems.

Take a look at the section of docs that cover thread interruption and the boost::thread_interrupted exception and fashion something that allows you to accomplish what you want while also cleaning things up.

Problem

Can you cancel a Boost Thread as you would a pthread? I'm writing a simple watchdog to terminate worker threads if they crash and there doesn't seem to be a way to simply cancel a thread in the Boost Thread library.

Original source