perf(library/shared_environment): replace shared_mutex with simple mutex, the shared_mutex is just overhead and impacts negatively on performance tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
045a83153c
commit
6129cccc66
2 changed files with 6 additions and 6 deletions
|
@ -11,27 +11,27 @@ 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);
|
||||
unique_lock<mutex> l(m_mutex);
|
||||
return m_env;
|
||||
}
|
||||
|
||||
void shared_environment::add(certified_declaration const & d) {
|
||||
exclusive_lock l(m_mutex);
|
||||
unique_lock<mutex> l(m_mutex);
|
||||
m_env = m_env.add(d);
|
||||
}
|
||||
|
||||
void shared_environment::add(declaration const & d) {
|
||||
exclusive_lock l(m_mutex);
|
||||
unique_lock<mutex> l(m_mutex);
|
||||
m_env = m_env.add(d);
|
||||
}
|
||||
|
||||
void shared_environment::replace(certified_declaration const & t) {
|
||||
exclusive_lock l(m_mutex);
|
||||
unique_lock<mutex> 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);
|
||||
unique_lock<mutex> l(m_mutex);
|
||||
m_env = f(m_env);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace lean {
|
|||
/** \brief Auxiliary object used when multiple threads are trying to populate the same environment. */
|
||||
class shared_environment {
|
||||
environment m_env;
|
||||
mutable shared_mutex m_mutex;
|
||||
mutable mutex m_mutex;
|
||||
public:
|
||||
shared_environment();
|
||||
shared_environment(environment const & env);
|
||||
|
|
Loading…
Reference in a new issue