add Timer::close()
An aid to orderly shutdown
This commit is contained in:
@@ -75,6 +75,8 @@ public:
|
||||
*/
|
||||
Timer(std::string threadName, ThreadPriority priority);
|
||||
virtual ~Timer();
|
||||
//! Prevent new callbacks from being scheduled, and cancel pending callbacks
|
||||
void close();
|
||||
/**
|
||||
* schedule a callback after a delay.
|
||||
* @param timerCallback the timerCallback instance.
|
||||
|
||||
@@ -160,8 +160,14 @@ void Timer::run()
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
close();
|
||||
}
|
||||
|
||||
void Timer::close() {
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(!alive)
|
||||
return; // already closed
|
||||
alive = false;
|
||||
}
|
||||
waitForWork.signal();
|
||||
|
||||
Reference in New Issue
Block a user