2014-05-20 22:42:52 +00:00
|
|
|
/*
|
|
|
|
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 {
|
2014-06-08 03:55:25 +00:00
|
|
|
lock_guard<mutex> l(m_mutex);
|
2014-05-20 22:42:52 +00:00
|
|
|
return m_env;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shared_environment::add(certified_declaration const & d) {
|
2014-06-08 03:55:25 +00:00
|
|
|
lock_guard<mutex> l(m_mutex);
|
2014-05-20 22:42:52 +00:00
|
|
|
m_env = m_env.add(d);
|
|
|
|
}
|
|
|
|
|
2014-05-21 18:54:29 +00:00
|
|
|
void shared_environment::add(declaration const & d) {
|
2014-06-08 03:55:25 +00:00
|
|
|
lock_guard<mutex> l(m_mutex);
|
2014-05-21 18:54:29 +00:00
|
|
|
m_env = m_env.add(d);
|
|
|
|
}
|
|
|
|
|
2014-05-20 22:42:52 +00:00
|
|
|
void shared_environment::replace(certified_declaration const & t) {
|
2014-06-08 03:55:25 +00:00
|
|
|
lock_guard<mutex> l(m_mutex);
|
2014-05-20 22:42:52 +00:00
|
|
|
m_env = m_env.replace(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shared_environment::update(std::function<environment(environment const &)> const & f) {
|
2014-06-08 03:55:25 +00:00
|
|
|
lock_guard<mutex> l(m_mutex);
|
2014-05-20 22:42:52 +00:00
|
|
|
m_env = f(m_env);
|
|
|
|
}
|
|
|
|
}
|