pthread_cancel and EH: let's try this again

Alexander Terekhov terekhov at web.de
Sat Jul 16 14:43:00 UTC 2005


Alexander Terekhov wrote:
> 
> Peter Dimov wrote:
> [...]
> > Keeping the cancellation request active doesn't need to be done by
> > reasserting in the destructor. It can simply be left active. Since
> > cancellation is implicitly disabled during stack unwinding,
> 
> No. Intelligent cancel delivery aside for a moment, it's explicitly
> disabled only after delivery (and pthread_exit()). Consider:
> 
>   some_dtor() throw() {
>     if (active_exception<thread_cancel_request>(0)) {
>       pthread_cancel(pthread_self());
>       pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &errno);
>       try {
>         fclose(temp_dataset); // no need to flush
>       }
>       catch(...) { }
>     }
>     else {
>       try {
>         fclose(temp_dataset); // no need to flush if we hit cancel
>       }
>       catch(...) { // canceled
>         pthread_cancel(pthread_self());
          pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &errno);
>       }
>     }
>   }
 
regards,
alexander.




More information about the c++-pthreads mailing list