[c++-pthreads] Re: cancellation points report failure
Alexander Terekhov
boo at terekhov.de
Tue Dec 30 13:58:29 UTC 2003
David Abrahams wrote:
[...]
> Of course it's not safe. That's my point, sort of: if you use
> synchronous cancellation, you have to give up on any *guarantee* that
> the thread will be cancelled, so we shouldn't be considering measures
> that take heroic steps to try to ensure it. If you want to guarantee
> that cancellation happens, you have to do something unsafe.
Note that the use of POSIX asynchronous cancellation (I mean the
presence of async-cancel{-safe} regions on the execution path) does
NOT guarantee thread termination (cancel request delivery) at all.
Conforming implementations are free to ignore it completely, so to
speak. I wish the standard would define pthread_testcancel() "in
terms" of an empty async-cancel region (and it would also provide
async-cancel-safety for pthread_testcancel() itself):
void pthread_testcancel() { /* mandatory shall occur semantics */
int oldtype;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
pthread_setcanceltype(oldtype, &oldtype);
}
regards,
alexander.
More information about the c++-pthreads
mailing list