I've been searching the documentation for Boost::Thread and I can't seem to figure out how to terminate a thread before it has completed I know when I was using the Windows Threading functions I was able to terminate a thread in the middle of execution. Is there anyway to do this with a Boost::Thread?
Never mind... did some more reading. Can't just call ThreadQuit() or something along those lines I have to essentially add a bunch of if statements checking if the thread should still be running. If so then do what needs to in order to close the thread.
Yep. Forcefully "killing" your thread is generally considered bad.
If your thread performs multiple lengthy operations, as apposed to short loop, you just have have to scatter "if (I_should_exit)" about appropriately - where the signal to exit is accomplished using something like boost::condition.
Since Boost 1.35, the thread class also has a member called interrupt(), which kills the thread, but only at some special interruption points. (Any of the sleeping functions of the thread library, basically.)
In particular, the if(I_should_exit) could be simply written as boost::this_thread::interruption_point(), as long as your catch the boost::thread_interrupted that will be thrown.