remove mutex in options

as it shouldn't be written to concurrently
This commit is contained in:
2024-04-07 23:03:45 +02:00
parent 34d31dea77
commit cd6a7a460c
2 changed files with 1 additions and 7 deletions

View File

@@ -18,7 +18,6 @@ public:
template<typename T> template<typename T>
static T get(const std::string &opt) { static T get(const std::string &opt) {
Options &o = get(); Options &o = get();
std::shared_lock l(o._mutex);
if (_defaults.find(opt) == _defaults.end()) throw std::invalid_argument("Unknown option " + opt); if (_defaults.find(opt) == _defaults.end()) throw std::invalid_argument("Unknown option " + opt);
if (!std::holds_alternative<T>(_defaults.at(opt))) throw std::invalid_argument("Bad option type " + opt); if (!std::holds_alternative<T>(_defaults.at(opt))) throw std::invalid_argument("Bad option type " + opt);
return std::get<T>(o._current.at(opt)); return std::get<T>(o._current.at(opt));
@@ -27,7 +26,6 @@ public:
template<typename T> template<typename T>
static void set(const std::string &opt, const T &val) { static void set(const std::string &opt, const T &val) {
Options &o = get(); Options &o = get();
std::lock_guard l(o._mutex);
if (_defaults.find(opt) == _defaults.end()) throw std::invalid_argument("Unknown option " + opt); if (_defaults.find(opt) == _defaults.end()) throw std::invalid_argument("Unknown option " + opt);
if (!std::holds_alternative<T>(_defaults.at(opt))) throw std::invalid_argument("Bad option type " + opt); if (!std::holds_alternative<T>(_defaults.at(opt))) throw std::invalid_argument("Bad option type " + opt);
o._current[opt] = val; o._current[opt] = val;
@@ -44,7 +42,6 @@ private:
{"repl", true}}; {"repl", true}};
std::unordered_map<std::string, std::variant<size_t, bool>> _current = _defaults; std::unordered_map<std::string, std::variant<size_t, bool>> _current = _defaults;
std::shared_mutex _mutex;
}; };

View File

@@ -11,7 +11,4 @@ Options &Options::get() {
return opts; return opts;
} }
void Options::reset() { void Options::reset() { get()._current = _defaults; }
std::lock_guard l(get()._mutex);
get()._current = _defaults;
}