Re: [c++-pthreads] cancellation points report failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] cancellation points report failure
- To: Nathan Myers <ncm@xxxxxxxxxxx>
- Subject: Re: [c++-pthreads] cancellation points report failure
- From: "Alexander Terekhov" <TEREKHOV@xxxxxxxxxx>
- Date: Sat, 20 Dec 2003 18:00:49 +0100
Nathan Myers wrote:
[...]
> C library and system calls never throw.
> In the event of cancellation, cancellation point functions report
> failure via their normal means (e.g. return -1, or NULL), and set
> errno if appropriate. Blocked calls fail immediately.
This will essentially break a lot of existing C/C++ code that is
cancel-safe and doesn't known how to handle ECANCELED "error"
(instead of expected behavior -- exception/unwinding).
> In a catch block handling a cancellation exception, functions
> identified as cancellation points work normally.
They work normally because "When a cancellation request is acted
upon, or when a thread calls pthread_exit(), the thread first
disables cancellation by setting its cancelability state to
PTHREAD_CANCEL_DISABLE and its cancelability type to
PTHREAD_CANCEL_DEFERRED. " And, in plain-C POSIX, "The behavior
is undefined if a cancellation cleanup handler or thread-
specific data destructor routine changes the cancelability
state to PTHREAD_CANCEL_ENABLE" (source: TC2).
> When a cancellation exception is swallowed by a catch block,
> subsequently-called cancellation point functions report failure,
> as before, until another cancellation exception is thrown.
That's sticky cancel. Not fun if you're using cancel for canceling
*jobs* and really want to reuse worker threads (your simply catch
and finalize cancel exception, enable cancel again, and continue
with next job).
regards,
alexander.