Use boost asio post to fix build

This commit is contained in:
emeric
2025-02-10 16:54:25 +01:00
parent cefa60e734
commit c9fb398196
3 changed files with 19 additions and 16 deletions
@@ -24,6 +24,7 @@
#include <Wt/Json/Serializer.h>
#include <Wt/Json/Value.h>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/post.hpp>
#include "ListensParser.hpp"
#include "core/IConfig.hpp"
@@ -245,14 +246,14 @@ namespace lms::scrobbling::listenBrainz
request.priority = core::http::ClientRequestParameters::Priority::Normal;
request.onSuccessFunc = [this, timedListen](std::string_view) {
_strand.dispatch([this, timedListen] {
boost::asio::post(boost::asio::bind_executor(_strand, [this, timedListen] {
if (saveListen(timedListen, db::SyncState::Synchronized))
{
UserContext& context{ getUserContext(timedListen.userId) };
if (context.listenCount)
(*context.listenCount)++;
}
});
}));
};
// on failure, this listen will be sent during the next sync
}
@@ -430,13 +431,13 @@ namespace lms::scrobbling::listenBrainz
void ListensSynchronizer::onSyncEnded(UserContext& context)
{
_strand.dispatch([this, &context] {
boost::asio::post(boost::asio::bind_executor(_strand, [this, &context] {
LOG(INFO, "Sync done for user '" << context.listenBrainzUserName << "', fetched: " << context.fetchedListenCount << ", matched: " << context.matchedListenCount << ", imported: " << context.importedListenCount);
context.syncing = false;
if (!isSyncing())
scheduleSync(_syncListensPeriod);
});
}));
}
void ListensSynchronizer::enqueValidateToken(UserContext& context)
@@ -479,7 +480,7 @@ namespace lms::scrobbling::listenBrainz
request.priority = core::http::ClientRequestParameters::Priority::Low;
request.onSuccessFunc = [this, &context](std::string_view msgBody) {
const auto listenCount{ parseListenCount(msgBody) };
_strand.dispatch([this, listenCount, &context] {
boost::asio::post(boost::asio::bind_executor(_strand, [this, listenCount, &context] {
if (listenCount)
LOG(DEBUG, "Listen count for listenbrainz user '" << context.listenBrainzUserName << "' = " << *listenCount);
@@ -494,7 +495,7 @@ namespace lms::scrobbling::listenBrainz
context.maxDateTime = Wt::WDateTime::currentDateTime();
enqueGetListens(context);
});
}));
};
request.onFailureFunc = [this, &context] {
onSyncEnded(context);