4
#include "noncopyable.h"
6
class CancellableBusyThread : public ost::Thread {
8
CancellableBusyThread() : started_(true), x_(0)
20
/* terminate() should always be called at the start of any
21
* destructor of a class derived from Thread to assure the remaining
22
* part of the destructor is called without the thread still executing.
24
virtual ~CancellableBusyThread()
26
std::cout << __PRETTY_FUNCTION__ << std::endl;
27
ost::Thread::terminate();
35
NON_COPYABLE(CancellableBusyThread);
38
class EventThread : public ost::Thread {
40
EventThread() : ost::Thread(), x_(0), event_()
48
// called from other threads
54
/* terminate() should always be called at the start of any
55
* destructor of a class derived from Thread to assure the remaining
56
* part of the destructor is called without the thread still executing.
58
virtual ~EventThread()
60
ost::Thread::terminate();
61
std::cout << __PRETTY_FUNCTION__ << std::endl;
70
EventThread *th = new EventThread;
73
std::cout << "event has happened..." << std::endl;
77
std::auto_ptr<CancellableBusyThread> busy(new CancellableBusyThread);
78
std::cout << "Starting busy thread" << std::endl;
80
busy->started_ = false;
82
std::cout << "Finished busy thread" << std::endl;