Re: [c++-pthreads] Restating the Jason model
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Restating the Jason model



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.