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/HttpServer.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/HttpServer.cc') 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; } -- cgit v1.2.3