[c++-pthreads] Re: pthread_cancel and EH: let's try this again

Wil Evers wil at bogo.xs4all.nl
Mon Jul 18 21:55:38 UTC 2005


Alexander Terekhov wrote:

> Wil Evers wrote:
> [...]
> 
>>     {
>>       cancellation_manager enabler(true);
>>       some_cancellation_point();
>>     }
> 
> 
> Never do that in "library" code.
> 
> http://www.opengroup.org/onlinepubs/009695399/functions/pthread_setcancelstate.html

That's great advice.  This should work too:

X::~X()
{
	try {
		cancellation_manager enabler(true);
		some_blocking_operation();
	} catch (const cancellation & ex) {
		// log ex
		// don't rethrow
	}
}

- Wil



More information about the c++-pthreads mailing list