Re: [c++-pthreads] Re: thread-safety definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Re: thread-safety definition
- To: David Abrahams <dave@xxxxxxxxxxxxxxxxxxxx>
- Subject: Re: [c++-pthreads] Re: thread-safety definition
- From: Ted Baker <baker@xxxxxxxxxx>
- Date: Sat, 10 Jan 2004 10:20:08 -0500
> >> Jason's model cancellation gets reasserted as soon as a caught
> >> cancellation exception is destroyed by falling off the end of the
> >> catch block without rethrowing.
> >
> > What if, at that point, the thread has disabled cancellation?
>
> Naturally, no cancellation exceptions are thrown until cancellation is
> re-enabled (I think).
BTW, it is important to distinguish between user-level
enabling/disabling of cancellation and what may go on in the
language implementation. You do not want some erroneous user
code (e.g., a cleanup routine that disables cancellation) to
break the language implementation of exception propagation.
Therefore, the implementor may provide a lower-level mechanism,
that supersedes or ignores whatever cancellation state the user set.
The user-level cancellation enable/disable bit essentially just
tells whether the various cancellation point routines should
initiate cancellation processing if there is a pending
cancellation, e.g.,
if (self->cancellation_enabled && self->cancellation_state == pending) {
self->cancellation_state = cancelling;
throw_exception (cancellation); // a runtime system call
}
This does not prevent the language runtime from *re*initiating
cancellation processing at other points where it makes sense,
e.g.,
if (self->cancellation_state == cancelling)
throw_exception (cancellation);
--Ted