diff --git a/src/qlobber_base.h b/src/qlobber_base.h index 0711f0c..810bbca 100644 --- a/src/qlobber_base.h +++ b/src/qlobber_base.h @@ -111,7 +111,6 @@ class QlobberBase { Options options; std::unordered_map> shortcuts; - std::shared_mutex mutex; virtual void add_values(MatchResult& r, const ValueStorage& vals, @@ -139,6 +138,8 @@ class QlobberBase { std::variant v; } trie; + std::shared_mutex mutex; + ValueStorage& add(const Value& val, const std::size_t i, const std::vector& words, diff --git a/src/qlobber_js_base.h b/src/qlobber_js_base.h index 03d6d35..4c17603 100644 --- a/src/qlobber_js_base.h +++ b/src/qlobber_js_base.h @@ -66,20 +66,6 @@ class QlobberJSCommon : return JSOptions::get(info.Env(), this->options); } - template - struct Puller { - typedef typename boost::coroutines2::coroutine coro_t; - typedef typename coro_t::pull_type pull_t; - Puller(pull_t source) : - source(std::move(source)), - it(begin(this->source)), - it_end(end(this->source)) {} - pull_t source; - typename pull_t::iterator it, it_end; - }; - - using Visitor = Puller>; - Napi::Value GetVisitor(const Napi::CallbackInfo& info) { return Napi::External::New( info.Env(), @@ -129,14 +115,6 @@ class QlobberJSCommon : return r; } - struct Restorer { - typedef typename boost::coroutines2::coroutine> coro_visit_t; - typedef typename coro_visit_t::push_type push_t; - Restorer(push_t sink) : - sink(std::move(sink)) {} - push_t sink; - }; - Napi::Value GetRestorer(const Napi::CallbackInfo& info) { bool cache_adds = false; if ((info.Length() > 0) && info[0].IsObject()) { @@ -189,8 +167,6 @@ class QlobberJSCommon : return info.Env().Undefined(); } - using Iterator = Puller; - Napi::Value MatchIter(const Napi::CallbackInfo& info) { return Napi::External::New( info.Env(), @@ -242,6 +218,30 @@ class QlobberJSCommon : virtual std::optional get_remove_value(const Napi::CallbackInfo& info) = 0; virtual TestValue get_test_value(const Napi::CallbackInfo& info) = 0; + +private: + template + struct Puller { + typedef typename boost::coroutines2::coroutine coro_t; + typedef typename coro_t::pull_type pull_t; + Puller(pull_t source) : + source(std::move(source)), + it(begin(this->source)), + it_end(end(this->source)) {} + pull_t source; + typename pull_t::iterator it, it_end; + }; + + using Visitor = Puller>; + using Iterator = Puller; + + struct Restorer { + typedef typename boost::coroutines2::coroutine> coro_visit_t; + typedef typename coro_visit_t::push_type push_t; + Restorer(push_t sink) : + sink(std::move(sink)) {} + push_t sink; + }; }; template