diff options
author | Yuri Gorshenin <y@maps.me> | 2016-09-01 17:23:57 +0300 |
---|---|---|
committer | Yuri Gorshenin <y@maps.me> | 2016-09-01 18:27:59 +0300 |
commit | 30ef25bfb34beab674320723f1bcc598a784fffe (patch) | |
tree | df87e64e58605358d779142f389eca51bde4af1a /editor | |
parent | a43c309fc7adfbd853133debc712a86be3d149f9 (diff) |
[indexer] Removed indexer dependency on search.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_config.hpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/editor/editor_config.hpp b/editor/editor_config.hpp index f4217e1371..7e55b35549 100644 --- a/editor/editor_config.hpp +++ b/editor/editor_config.hpp @@ -2,6 +2,7 @@ #include "indexer/feature_meta.hpp" +#include "std/mutex.hpp" #include "std/shared_ptr.hpp" #include "std/string.hpp" #include "std/vector.hpp" @@ -59,10 +60,24 @@ class EditorConfigWrapper public: EditorConfigWrapper() = default; - void Set(shared_ptr<EditorConfig> config) { atomic_store(&m_config, config); } - shared_ptr<EditorConfig const> Get() const { return atomic_load(&m_config); } + void Set(shared_ptr<EditorConfig> config) + { + lock_guard<mutex> lock(m_mu); + m_config = config; + } + + shared_ptr<EditorConfig const> Get() const + { + lock_guard<mutex> lock(m_mu); + return m_config; + } private: + // It's possible to use atomic_{load|store} here instead of mutex, + // but seems that libstdc++4.9 doesn't support it. Need to rewrite + // this code as soon as libstdc++5 will be ready for lastest Debian + // release, or as soon as atomic_shared_ptr will be ready. + mutable mutex m_mu; shared_ptr<EditorConfig> m_config = make_shared<EditorConfig>(); // Just in case someone tryes to pass EditorConfigWrapper by value instead of referense. |