Skip to content

Commit

Permalink
Adjust privacy a bit again
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Nov 14, 2019
1 parent 9ab1813 commit a71ce13
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/qlobber_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class QlobberBase {

Options options;
std::unordered_map<std::string, std::reference_wrapper<ValueStorage>> shortcuts;
std::shared_mutex mutex;

virtual void add_values(MatchResult& r,
const ValueStorage& vals,
Expand Down Expand Up @@ -139,6 +138,8 @@ class QlobberBase {
std::variant<map_ptr, ValueStorage> v;
} trie;

std::shared_mutex mutex;

ValueStorage& add(const Value& val,
const std::size_t i,
const std::vector<std::string>& words,
Expand Down
48 changes: 24 additions & 24 deletions src/qlobber_js_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@ class QlobberJSCommon :
return JSOptions::get(info.Env(), this->options);
}

template<typename T>
struct Puller {
typedef typename boost::coroutines2::coroutine<T> 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<Visit<Value>>;

Napi::Value GetVisitor(const Napi::CallbackInfo& info) {
return Napi::External<Visitor>::New(
info.Env(),
Expand Down Expand Up @@ -129,14 +115,6 @@ class QlobberJSCommon :
return r;
}

struct Restorer {
typedef typename boost::coroutines2::coroutine<Visit<Value>> 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()) {
Expand Down Expand Up @@ -189,8 +167,6 @@ class QlobberJSCommon :
return info.Env().Undefined();
}

using Iterator = Puller<IterValue>;

Napi::Value MatchIter(const Napi::CallbackInfo& info) {
return Napi::External<Iterator>::New(
info.Env(),
Expand Down Expand Up @@ -242,6 +218,30 @@ class QlobberJSCommon :
virtual std::optional<const RemoveValue> get_remove_value(const Napi::CallbackInfo& info) = 0;

virtual TestValue get_test_value(const Napi::CallbackInfo& info) = 0;

private:
template<typename T>
struct Puller {
typedef typename boost::coroutines2::coroutine<T> 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<Visit<Value>>;
using Iterator = Puller<IterValue>;

struct Restorer {
typedef typename boost::coroutines2::coroutine<Visit<Value>> coro_visit_t;
typedef typename coro_visit_t::push_type push_t;
Restorer(push_t sink) :
sink(std::move(sink)) {}
push_t sink;
};
};

template<typename Value,
Expand Down

0 comments on commit a71ce13

Please sign in to comment.