summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HttpServer.cc10
-rw-r--r--src/Printer.cc3
-rw-r--r--src/TaskMan.cc9
3 files changed, 7 insertions, 15 deletions
diff --git a/src/HttpServer.cc b/src/HttpServer.cc
index c596005..fe421b9 100644
--- a/src/HttpServer.cc
+++ b/src/HttpServer.cc
@@ -607,21 +607,19 @@ void Balau::HttpServer::stop() {
}
void Balau::HttpServer::registerAction(Action * action) {
- m_actionsLock.enterW();
+ ScopeLockW slw(m_actionsLock);
action->ref();
m_actions.push_front(action);
- m_actionsLock.leave();
}
void Balau::HttpServer::flushAllActions() {
- m_actionsLock.enterW();
+ ScopeLockW slw(m_actionsLock);
Action * a;
while (!m_actions.empty()) {
a = m_actions.front();
m_actions.pop_front();
a->unref();
}
- m_actionsLock.leave();
}
Balau::HttpServer::Action::ActionMatch Balau::HttpServer::Action::matches(const char * uri, const char * host) {
@@ -636,7 +634,7 @@ Balau::HttpServer::Action::ActionMatch Balau::HttpServer::Action::matches(const
}
Balau::HttpServer::ActionFound Balau::HttpServer::findAction(const char * uri, const char * host) {
- m_actionsLock.enterR();
+ ScopeLockR slr(m_actionsLock);
ActionList::iterator i;
ActionFound r;
@@ -653,8 +651,6 @@ Balau::HttpServer::ActionFound Balau::HttpServer::findAction(const char * uri, c
else
r.action->ref();
- m_actionsLock.leave();
-
return r;
}
diff --git a/src/Printer.cc b/src/Printer.cc
index 026ee1a..ee6029c 100644
--- a/src/Printer.cc
+++ b/src/Printer.cc
@@ -40,7 +40,7 @@ void Balau::Printer::_log(uint32_t level, const char * fmt, va_list ap) {
if (l & level)
break;
- m_lock.enter();
+ ScopeLock sl(m_lock);
if (m_detailledLogs) {
struct ev_loop * loop = ev_default_loop(0);
ev_now_update(loop);
@@ -50,7 +50,6 @@ void Balau::Printer::_log(uint32_t level, const char * fmt, va_list ap) {
_print(prefixes[i]);
_print(fmt, ap);
_print("\n");
- m_lock.leave();
}
void Balau::Printer::_print(const char * fmt, va_list ap) {
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() {