Re: [c++-pthreads] Re: FW: RE: Re: I'm Lost
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Re: FW: RE: Re: I'm Lost
- To: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
- Subject: Re: [c++-pthreads] Re: FW: RE: Re: I'm Lost
- From: Alexander Terekhov <TEREKHOV@xxxxxxxxxx>
- Date: Thu, 9 Mar 2006 09:21:24 +0100
Mark Mitchell <mark@xxxxxxxxxxxxxxxx> wrote:
[...]
> It sounds like we really are close to a solution then; I think everyone
> here would be happy with the re-cancellation thing, and the destructor
> trick
It would not satisfy me. For one. Cancel unaware code should be made
cancel aware with "pthread_cancel (pthread_self ())" added only if/when
it is really needed. I mean stuff like
void oper() throw(int) {
/**/
fclose(/*..*/); // doesn't throw; cancel is unexpected -- language
// change with mandatory 2-phase EH and intelligent
// cancel delivery is required
}
transformed to
void oper() throw(int) {
/**/
try {
fclose(/*..*/); // can throw; cancel IS expected -- catch below
}
catch (std::thread_cancel_request const &) {
/**/
std::enable_thread_cancel(); // re-enable cancel state
std::thread_self().cancel(); // re-inject cancel request
/**/
}
}
Well, I guess I could live with
catch (std::thread_cancel_request & tcr) {
tcr.stop_stupid_stickyness();
}
but that's somewhat unsatisfying, so to speak.
regards,
alexander.
Mark Mitchell <mark@xxxxxxxxxxxxxxxx> on 09.03.2006 00:15:37
To: Jason Merrill <jason@xxxxxxxxxx>
cc: Wil Evers <wil@xxxxxxxxxxxxxx>, David Abrahams
<dave@xxxxxxxxxxxxxxxxxxxx>, c++-pthreads@xxxxxxxxxxxxxxxx
Subject: Re: [c++-pthreads] Re: FW: RE: Re: I'm Lost
Jason Merrill wrote:
> If you can interrupt cancellation, re-cancellation is implemented
> trivially simply by just having the cancellation exception destructor
> call 'pthread_cancel (pthread_self ())'. The sticking point is being
> able to abort the cancellation in the first place, which is what Uli has
> been opposed to.
It sounds like we really are close to a solution then; I think everyone
here would be happy with the re-cancellation thing, and the destructor
trick means that there's really no way the thread can permanently
discard the cancellation request, short of things like longjmp -- and,
of course, if the thread is really determined not to go away it can just
hang around anyhow. So, it seems like this ought to satisfy everyone
from the user-level perspective.
> I don't think he's opposed to catching it, just to doing anything that
> would involve backing out of the cancellation once it's started.
Would the above satisfy him?
--
Mark Mitchell
CodeSourcery
mark@xxxxxxxxxxxxxxxx
(650) 331-3385 x713