[c++-pthreads] Re: pthread_cancel and EH: let's try this again
Peter Dimov
pdimov at mmltd.net
Sat Jul 16 15:22:11 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());
> }
> }
> }
I don't get it. What is this code supposed to achieve?
More information about the c++-pthreads
mailing list