chore(*): replace unique_lock with lock_guard when we do not need to use conditional variables
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
fb5c7c8e92
commit
1c49b4d85f
2 changed files with 6 additions and 6 deletions
|
@ -48,7 +48,7 @@ environment_id::environment_id():m_ptr(new path()), m_depth(0) {}
|
||||||
environment_id::environment_id(environment_id const & ancestor, bool) {
|
environment_id::environment_id(environment_id const & ancestor, bool) {
|
||||||
if (ancestor.m_depth == std::numeric_limits<unsigned>::max())
|
if (ancestor.m_depth == std::numeric_limits<unsigned>::max())
|
||||||
throw exception("maximal depth in is_descendant tree has been reached, use 'forget' method to workaround this limitation");
|
throw exception("maximal depth in is_descendant tree has been reached, use 'forget' method to workaround this limitation");
|
||||||
unique_lock<mutex> lock(ancestor.m_ptr->m_mutex);
|
lock_guard<mutex> lock(ancestor.m_ptr->m_mutex);
|
||||||
if (ancestor.m_ptr->m_next_depth == ancestor.m_depth + 1) {
|
if (ancestor.m_ptr->m_next_depth == ancestor.m_depth + 1) {
|
||||||
m_ptr = ancestor.m_ptr;
|
m_ptr = ancestor.m_ptr;
|
||||||
m_depth = ancestor.m_depth + 1;
|
m_depth = ancestor.m_depth + 1;
|
||||||
|
|
|
@ -11,27 +11,27 @@ shared_environment::shared_environment() {}
|
||||||
shared_environment::shared_environment(environment const & env):m_env(env) {}
|
shared_environment::shared_environment(environment const & env):m_env(env) {}
|
||||||
|
|
||||||
environment shared_environment::get_environment() const {
|
environment shared_environment::get_environment() const {
|
||||||
unique_lock<mutex> l(m_mutex);
|
lock_guard<mutex> l(m_mutex);
|
||||||
return m_env;
|
return m_env;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shared_environment::add(certified_declaration const & d) {
|
void shared_environment::add(certified_declaration const & d) {
|
||||||
unique_lock<mutex> l(m_mutex);
|
lock_guard<mutex> l(m_mutex);
|
||||||
m_env = m_env.add(d);
|
m_env = m_env.add(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shared_environment::add(declaration const & d) {
|
void shared_environment::add(declaration const & d) {
|
||||||
unique_lock<mutex> l(m_mutex);
|
lock_guard<mutex> l(m_mutex);
|
||||||
m_env = m_env.add(d);
|
m_env = m_env.add(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shared_environment::replace(certified_declaration const & t) {
|
void shared_environment::replace(certified_declaration const & t) {
|
||||||
unique_lock<mutex> l(m_mutex);
|
lock_guard<mutex> l(m_mutex);
|
||||||
m_env = m_env.replace(t);
|
m_env = m_env.replace(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shared_environment::update(std::function<environment(environment const &)> const & f) {
|
void shared_environment::update(std::function<environment(environment const &)> const & f) {
|
||||||
unique_lock<mutex> l(m_mutex);
|
lock_guard<mutex> l(m_mutex);
|
||||||
m_env = f(m_env);
|
m_env = f(m_env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue