FW: Re: pthread_cancel and EH: let's try this again

Alexander Terekhov terekhov at web.de
Thu Jul 21 15:22:47 UTC 2005


George Shimanovich wrote:
[...]
> Exactly. The reason why some applications cannot rethrow caught
> cancellation exception (Linux/gcc) was that worker threads in typical
> thread pool implementation are reusable. Explicit call to clear pending
> cancellation request will allow cancelled worker thread to return to
> list of idle threads.

#include <pthread> // C++ extras

void clear_pending_cancellation_request() {
  try {
    // it has throw(std::thread_cancel_request) ES
    std::pthread_testcancel(); 
  }
  catch(...) {
    std::pthread_setcancelstate(PTHREAD_CANCEL_ENABLE); 
  }
}

regards,
alexander.




More information about the c++-pthreads mailing list