conversation: callback without lock

Change-Id: I01574e819210c853c8cdbcde6f366956b61b8077
This commit is contained in:
Adrien Béraud
2025-07-18 00:01:30 -04:00
parent 8310709827
commit 796dd8a185

View File

@ -1717,8 +1717,10 @@ Conversation::loadMessages2(const OnLoadMessages2& cb, const LogOptions& options
return;
dht::ThreadPool::io().run([w = weak(), cb = std::move(cb), options] {
if (auto sthis = w.lock()) {
std::lock_guard lk(sthis->pimpl_->loadedHistory_.mutex);
cb(sthis->pimpl_->loadMessages2(options));
std::unique_lock lk(sthis->pimpl_->loadedHistory_.mutex);
auto result = sthis->pimpl_->loadMessages2(options);
lk.unlock();
cb(std::move(result));
}
});
}