From 243b1d7d451e835682320d3142e9693fc7a91add Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 13 Jan 2009 18:52:19 +0000 Subject: 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 --- cpp/src/qpid/broker/Timer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/broker/Timer.cpp') 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 t = tasks.top(); - if (t->cancelled) { + if (t->isCancelled()) { tasks.pop(); } else if(t->time < AbsTime::now()) { tasks.pop(); -- cgit v1.2.1