store: expose the mutex so we can lock query-results

The QueryResults must not outlive the lock (when in a MT context), so expose for
clients (mu-server) to handle it.
This commit is contained in:
Dirk-Jan C. Binnema
2022-02-17 23:45:04 +02:00
parent 4eabf1a64a
commit 831d26052a
2 changed files with 10 additions and 2 deletions

View File

@ -662,14 +662,18 @@ Store::for_each_term(const std::string& field, Store::ForEachTermFunc func) cons
return n;
}
std::mutex&
Store::lock() const
{
return priv_->lock_;
}
Option<QueryResults>
Store::run_query(const std::string& expr, MuMsgFieldId sortfieldid,
QueryFlags flags, size_t maxnum) const
{
return xapian_try([&] {
std::lock_guard guard{priv_->lock_};
Query q{*this};
return q.run(expr, sortfieldid, flags, maxnum);
},
Nothing);