From 1c49b4d85f45d032904422120867e06bbcb0f055 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 7 Jun 2014 20:55:25 -0700 Subject: [PATCH] chore(*): replace unique_lock with lock_guard when we do not need to use conditional variables Signed-off-by: Leonardo de Moura --- src/kernel/environment.cpp | 2 +- src/library/shared_environment.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index ab7ead794..fdf114b31 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -48,7 +48,7 @@ environment_id::environment_id():m_ptr(new path()), m_depth(0) {} environment_id::environment_id(environment_id const & ancestor, bool) { if (ancestor.m_depth == std::numeric_limits::max()) throw exception("maximal depth in is_descendant tree has been reached, use 'forget' method to workaround this limitation"); - unique_lock lock(ancestor.m_ptr->m_mutex); + lock_guard lock(ancestor.m_ptr->m_mutex); if (ancestor.m_ptr->m_next_depth == ancestor.m_depth + 1) { m_ptr = ancestor.m_ptr; m_depth = ancestor.m_depth + 1; diff --git a/src/library/shared_environment.cpp b/src/library/shared_environment.cpp index b60b76e10..96e90ef47 100644 --- a/src/library/shared_environment.cpp +++ b/src/library/shared_environment.cpp @@ -11,27 +11,27 @@ shared_environment::shared_environment() {} shared_environment::shared_environment(environment const & env):m_env(env) {} environment shared_environment::get_environment() const { - unique_lock l(m_mutex); + lock_guard l(m_mutex); return m_env; } void shared_environment::add(certified_declaration const & d) { - unique_lock l(m_mutex); + lock_guard l(m_mutex); m_env = m_env.add(d); } void shared_environment::add(declaration const & d) { - unique_lock l(m_mutex); + lock_guard l(m_mutex); m_env = m_env.add(d); } void shared_environment::replace(certified_declaration const & t) { - unique_lock l(m_mutex); + lock_guard l(m_mutex); m_env = m_env.replace(t); } void shared_environment::update(std::function const & f) { - unique_lock l(m_mutex); + lock_guard l(m_mutex); m_env = f(m_env); } }