[c++-pthreads] Restating the Jason model
Alexander Terekhov
boo at terekhov.de
Tue Jan 13 13:59:11 UTC 2004
Dave Butenhof wrote:
[...]
> Absolutely; because the correct behavior of the application (which might
> be distributed) could depend on being able to notify the remote partner
> that the local thread is shutting down. Nathan's proposal doesn't allow
> that, and that's the big weakness.
Nathan's proposal does allow that (not that I really like Nathan's
proposal). You'd simply have to manually disable cancelation. Think of
"traditional" pthread_cleanup_pop(!0) handlers.
>
> Jason's proposal will cause the cancel to be re-asserted when the
> exception object is destroyed, on exit from the catch(), after local
> cleanup has been done. This makes the catch() behave (more or less) like
> a destructor.
And that's "the big" weakness. catch() != destructor.
void operation() throw(std::thread_cancel_request);
void f() {
try {
operation();
}
catch(...) {
pthread_exit("Wow, canceled."); // or something like that
}
/* ... */
}
regards,
alexander.
More information about the c++-pthreads
mailing list