From 2380ebca01bdff36c2d12b0a23bef84e07920cb3 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 8 Mar 2012 07:25:27 -0800 Subject: Adding the ScopeLock class to simplify a bit some pieces of code. --- src/TaskMan.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/TaskMan.cc') diff --git a/src/TaskMan.cc b/src/TaskMan.cc index 843423f..ea7a613 100644 --- a/src/TaskMan.cc +++ b/src/TaskMan.cc @@ -53,13 +53,12 @@ void Balau::TaskScheduler::registerTask(Task * t) { } void Balau::TaskScheduler::registerTaskMan(TaskMan * t) { - m_lock.enter(); + ScopeLock sl(m_lock); m_taskManagers.push(t); - m_lock.leave(); } void Balau::TaskScheduler::unregisterTaskMan(TaskMan * t) { - m_lock.enter(); + ScopeLock sl(m_lock); TaskMan * p = NULL; // yes, this is a potentially dangerous operation. // But unregistering task managers shouldn't happen that often. @@ -70,12 +69,11 @@ void Balau::TaskScheduler::unregisterTaskMan(TaskMan * t) { break; m_taskManagers.push(p); } - m_lock.leave(); } void Balau::TaskScheduler::stopAll(int code) { m_stopping = true; - m_lock.enter(); + ScopeLock sl(m_lock); std::queue altQueue; TaskMan * tm; while (!m_taskManagers.empty()) { @@ -90,7 +88,6 @@ void Balau::TaskScheduler::stopAll(int code) { altQueue.pop(); m_taskManagers.push(tm); } - m_lock.leave(); } void * Balau::TaskScheduler::proc() { -- cgit v1.2.3