store-worker: implement

store-worker is a thread + async queue to throttle requests to a single thread.
This commit is contained in:
Dirk-Jan C. Binnema
2024-05-26 14:20:47 +03:00
parent c05b28e761
commit cf9c09867f
5 changed files with 258 additions and 1 deletions

View File

@ -131,6 +131,7 @@ struct Store::Private {
XapianDb xapian_db_;
Config config_;
ContactsCache contacts_cache_;
std::unique_ptr<StoreWorker> store_worker_;
std::unique_ptr<Indexer> indexer_;
const std::string root_maildir_;
@ -252,6 +253,7 @@ Store::Store(Store&& other)
{
priv_ = std::move(other.priv_);
priv_->indexer_.reset();
priv_->store_worker_.reset();
}
Store::~Store() = default;
@ -316,6 +318,15 @@ Store::indexer()
return *priv_->indexer_.get();
}
StoreWorker&
Store::store_worker()
{
if (!priv_->store_worker_)
priv_->store_worker_ = std::make_unique<StoreWorker>(*this);
return *priv_->store_worker_;
}
Result<Store::Id>
Store::add_message(Message& msg, bool is_new)
{