From f8bf9e0bfdde526ad2a2b5fb5d1f008ee51ac098 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 29 Apr 2010 01:17:09 +0000 Subject: QPID-2186: Small adjustments to previous fix: - Turn one of the "if"s into an assert - Fix incorrect scope for unlocking Timer monitor around fire() callback. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@939156 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/Timer.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cpp/src/qpid/sys/Timer.cpp') diff --git a/cpp/src/qpid/sys/Timer.cpp b/cpp/src/qpid/sys/Timer.cpp index 55c48c5b9c..26d16e5188 100644 --- a/cpp/src/qpid/sys/Timer.cpp +++ b/cpp/src/qpid/sys/Timer.cpp @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -84,7 +84,7 @@ Timer::Timer() : start(); } -Timer::~Timer() +Timer::~Timer() { stop(); } @@ -114,8 +114,10 @@ void Timer::run() } continue; } else if(Duration(t->nextFireTime, start) >= 0) { + { Monitor::ScopedUnlock u(monitor); fire(t); + } // Warn if callback overran next timer's start. AbsTime end(AbsTime::now()); Duration overrun (0); @@ -149,8 +151,8 @@ void Timer::run() tasks.push(t); } } - if (!tasks.empty()) - monitor.wait(tasks.top()->sortTime); + assert(!tasks.empty()); + monitor.wait(tasks.top()->sortTime); } } } -- cgit v1.2.1