Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does the cancelation exception have a name?


  • To: c++-pthreads@xxxxxxxxxxxxxxxx
  • Subject: Re: Does the cancelation exception have a name?
  • From: Alexander Terekhov <terekhov@xxxxxx>
  • Date: Sat, 04 Nov 2006 22:25:50 +0100

#define PTHREAD_CANCELED std::thread_canceled()

struct thread_canceled {
  operator void * () { return &unique; }
  static thread_canceled unique;
};

extern "C" void pthread_exit(void * ptr)
	throw(std::thread_termination_request) {
  ptr == PTHREAD_CANCELED ? std::thread_cancel() :
                            std::thread_exit(ptr);

} 
template<typename T>
void thread_exit(T value) {
  assert(std::thread_self().can_exit_with<T>());
  throw thread_exit_value(value);
}

template<>
void thread_exit(std::thread_canceled) {
  thread_cancel();
}

void thread_cancel() {
  throw std::thread_cancel_request();
} 

regards,
alexender.