summaryrefslogtreecommitdiff
path: root/src/TaskMan.cc
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2012-03-08 07:25:27 -0800
committerPixel <pixel@nobis-crew.org>2012-03-08 07:46:59 -0800
commit2380ebca01bdff36c2d12b0a23bef84e07920cb3 (patch)
tree47dbc4523a2d6c61fed221fe4c67410fd107b2c4 /src/TaskMan.cc
parent85e533ca87fff1b7ab40bd87a3a44b6969eefd13 (diff)
Adding the ScopeLock class to simplify a bit some pieces of code.
Diffstat (limited to 'src/TaskMan.cc')
-rw-r--r--src/TaskMan.cc9
1 files changed, 3 insertions, 6 deletions
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<TaskMan *> 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() {