lean2/src/library/shared_environment.cpp
Leonardo de Moura dd3edcb19f feat(library): add shared environment object
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-20 15:42:52 -07:00

32 lines
858 B
C++

/*
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include "library/shared_environment.h"
namespace lean {
shared_environment::shared_environment() {}
shared_environment::shared_environment(environment const & env):m_env(env) {}
environment shared_environment::get_environment() const {
shared_lock l(m_mutex);
return m_env;
}
void shared_environment::add(certified_declaration const & d) {
exclusive_lock l(m_mutex);
m_env = m_env.add(d);
}
void shared_environment::replace(certified_declaration const & t) {
exclusive_lock l(m_mutex);
m_env = m_env.replace(t);
}
void shared_environment::update(std::function<environment(environment const &)> const & f) {
exclusive_lock l(m_mutex);
m_env = f(m_env);
}
}