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: Dave Butenhof <David.Butenhof@xxxxxx>
- Subject: Re: [c++-pthreads] Re: thread-safety definition
- From: Alexander Terekhov <boo@xxxxxxxxxxx>
- Date: Tue, 20 Jan 2004 14:42:55 +0100
Dave Butenhof wrote:
[...]
> than explicit API. I was thinking in terms of disabling cancel within a
> 'throw()' scope... but there might be other conditions. For example, we
> could disable inside either 'throw()' or any try with a catch(...) that
> doesn't rethrow... unless there's an INNER scope that allows throwing
> cancel AND with an explicit catch(cancel). So a nothrow destructor
> (regardless of whether all destructors were implicitly nothrow or not)
> could allow "local" cancellation by nesting a try{} catch(cancel) {}.
This will sort of "break" catch(...), I'm afraid.
>
> (Sounds too complicated; but it's something to think about. ;-) )
The C++ incarnation of pthread_testcancel() will surely have a throw
spec "throw(std::thread_cancel_request)" or something like that. Now
imagine something along the lines of
void oper(/*...*/) throw(std::thread_cancel_request, std::bad_alloc);
/*...*/ oper_throw_handlers(/*...*/) throw();
void f1() throw() {
/*...*/
try {
oper(/*... "X" ...*/);
}
catch(...) {
/*...*/oper_throw_handlers(/*...*/);
}
/*...*/
}
void f2() throw() {
/*...*/
try {
oper(/*... "Y" ...*/);
}
catch(...) {
/*...*/oper_throw_handlers(/*...*/);
}
/*...*/
}
void f3() throw() {
/*...*/
try {
oper(/*... "Z" ...*/);
}
catch(...) {
/*...*/oper_throw_handlers(/*...*/);
}
/*...*/
}
/*...*/ oper_throw_handlers() throw() {
try {
throw;
}
catch(std::bad_alloc const &) {
/*...*/
}
catch(std::thread_cancel_request const &) {
/*...*/
}
/*...*/
}
regards,
alexander.
P.S. http://google.com/groups?selm=4007FC34.D5A1059%40web.de
http://google.com/groups?selm=40095EC5.9FDB3513%40web.de
http://google.com/groups?selm=400960FF.558DC7DB%40web.de
(Subject: Re: is catch(...) safe)