
Dhanvi Kapila wrote:
What do you mean with "exit handlers"? Can you provide an example?
by exit handlers I mean some special function that would be gauranteed to be called whenever the thread is exiting. This is where my application can place specific code to be done on thread exit ?
There is something like that in boost::thread but it is only supported for win32. See boost/thread/detail/tss_hooks.hpp On the other hand, if what you want is to call a function when the thread is exiting "normally" (when the thread proc exits via normal flow or exception) then I think Sebastian's idea of a sentry object is the best and it is more portable. You can pass the "callback function" as a parameter to your thread proc (using bind) and initialize the local sentry object with it. -delfin