// file : examples/sched/cancel/cancel.cxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2010 Boris Kolpackov // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include #include #include #include #include #include #include #include // sleep using std::cerr; using std::endl; using namespace Cult; using namespace Sched; Void* cond_wait_thread_proc (Void*) { try { Mutex mutex; Condition cond (mutex); Lock lock (mutex); cond.wait (); } /* catch (std::thread_canceled const& e) { cerr << "caught thread_canceled" << endl; throw; } */ catch (...) { cerr << "presumably caught thread_canceled" << endl; throw; } return 0; } Int main () { Shptr thread (new Thread (cond_wait_thread_proc)); sleep (1); thread->cancel (); thread->join (); }