summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/Timer.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2009-01-13 18:52:19 +0000
committerAndrew Stitcher <astitcher@apache.org>2009-01-13 18:52:19 +0000
commit243b1d7d451e835682320d3142e9693fc7a91add (patch)
treecb504c91c9d31a270feef6f68d82441ee4e2eeaa /cpp/src/qpid/broker/Timer.cpp
parent73ba540688ac9d9145adee70b5489a91f2adf955 (diff)
downloadqpid-python-243b1d7d451e835682320d3142e9693fc7a91add.tar.gz
Start to fix Timer to improve encapsulation and then fix
its inbuilt race conditions (mostly due to the awkward interface of Timer and TimerTask) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@734213 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/Timer.cpp')
-rw-r--r--cpp/src/qpid/broker/Timer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/cpp/src/qpid/broker/Timer.cpp b/cpp/src/qpid/broker/Timer.cpp
index 0b0d3ba63d..46bbdbb574 100644
--- a/cpp/src/qpid/broker/Timer.cpp
+++ b/cpp/src/qpid/broker/Timer.cpp
@@ -38,6 +38,9 @@ TimerTask::~TimerTask(){}
void TimerTask::reset() { time = AbsTime(AbsTime::now(), duration); }
+void TimerTask::cancel() { cancelled = true; }
+bool TimerTask::isCancelled() const { return cancelled; }
+
Timer::Timer() : active(false)
{
start();
@@ -56,7 +59,7 @@ void Timer::run()
monitor.wait();
} else {
intrusive_ptr<TimerTask> t = tasks.top();
- if (t->cancelled) {
+ if (t->isCancelled()) {
tasks.pop();
} else if(t->time < AbsTime::now()) {
tasks.pop();