From c9fb3981964d642bc81f6df27835dfbe1bec3e2c Mon Sep 17 00:00:00 2001 From: emeric Date: Mon, 10 Feb 2025 16:54:25 +0100 Subject: [PATCH] Use boost asio post to fix build --- src/libs/core/impl/http/SendQueue.cpp | 5 +++-- .../impl/listenbrainz/FeedbacksSynchronizer.cpp | 17 +++++++++-------- .../impl/listenbrainz/ListensSynchronizer.cpp | 13 +++++++------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/libs/core/impl/http/SendQueue.cpp b/src/libs/core/impl/http/SendQueue.cpp index 3ed4655c..3becfb26 100644 --- a/src/libs/core/impl/http/SendQueue.cpp +++ b/src/libs/core/impl/http/SendQueue.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "core/Exception.hpp" #include "core/ILogger.hpp" @@ -64,9 +65,9 @@ namespace lms::core::http , _baseUrl{ baseUrl } { _client.done().connect([this](Wt::AsioWrapper::error_code ec, const Wt::Http::Message& msg) { - _strand.dispatch([this, ec, msg = std::move(msg)] { + boost::asio::post(boost::asio::bind_executor(_strand, [this, ec, msg = std::move(msg)] { onClientDone(ec, msg); - }); + })); }); } diff --git a/src/libs/services/feedback/impl/listenbrainz/FeedbacksSynchronizer.cpp b/src/libs/services/feedback/impl/listenbrainz/FeedbacksSynchronizer.cpp index 973225e1..a0a80c66 100644 --- a/src/libs/services/feedback/impl/listenbrainz/FeedbacksSynchronizer.cpp +++ b/src/libs/services/feedback/impl/listenbrainz/FeedbacksSynchronizer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "core/IConfig.hpp" #include "core/Service.hpp" @@ -132,9 +133,9 @@ namespace lms::feedback::listenBrainz request.message.addHeader("Content-Type", "application/json"); request.onSuccessFunc = [this, type, starredTrackId](std::string_view /*msgBody*/) { - _strand.dispatch([this, type, starredTrackId] { + boost::asio::post(boost::asio::bind_executor(_strand, [this, type, starredTrackId] { onFeedbackSent(type, starredTrackId); - }); + })); }; _client.sendPOSTRequest(std::move(request)); } @@ -295,13 +296,13 @@ namespace lms::feedback::listenBrainz void FeedbacksSynchronizer::onSyncEnded(UserContext& context) { - _strand.dispatch([this, &context] { + boost::asio::post(boost::asio::bind_executor(_strand, [this, &context] { LOG(INFO, "Feedback sync done for user '" << context.listenBrainzUserName << "', fetched: " << context.fetchedFeedbackCount << ", matched: " << context.matchedFeedbackCount << ", imported: " << context.importedFeedbackCount); context.syncing = false; if (!isSyncing()) scheduleSync(_syncFeedbacksPeriod); - }); + })); } void FeedbacksSynchronizer::enqueValidateToken(UserContext& context) @@ -344,7 +345,7 @@ namespace lms::feedback::listenBrainz request.priority = core::http::ClientRequestParameters::Priority::Low; request.onSuccessFunc = [this, &context](std::string_view msgBody) { std::string msgBodyCopy{ msgBody }; - _strand.dispatch([this, msgBodyCopy, &context] { + boost::asio::post(boost::asio::bind_executor(_strand, [this, msgBodyCopy, &context] { LOG(DEBUG, "Current feedback count = " << (context.feedbackCount ? *context.feedbackCount : 0) << " for user '" << context.listenBrainzUserName << "'"); const auto totalFeedbackCount = parseTotalFeedbackCount(msgBodyCopy); @@ -358,7 +359,7 @@ namespace lms::feedback::listenBrainz enqueGetFeedbacks(context); else onSyncEnded(context); - }); + })); }; request.onFailureFunc = [this, &context] { onSyncEnded(context); @@ -376,7 +377,7 @@ namespace lms::feedback::listenBrainz request.priority = core::http::ClientRequestParameters::Priority::Low; request.onSuccessFunc = [this, &context](std::string_view msgBody) { std::string msgBodyCopy{ msgBody }; - _strand.dispatch([this, msgBodyCopy, &context] { + boost::asio::post(boost::asio::bind_executor(_strand, [this, msgBodyCopy, &context] { const std::size_t fetchedFeedbackCount{ processGetFeedbacks(msgBodyCopy, context) }; if (fetchedFeedbackCount == 0 // no more thing available on server || context.fetchedFeedbackCount >= context.feedbackCount // we may miss something, but we will get it next time @@ -388,7 +389,7 @@ namespace lms::feedback::listenBrainz { enqueGetFeedbacks(context); } - }); + })); }; request.onFailureFunc = [this, &context] { onSyncEnded(context); diff --git a/src/libs/services/scrobbling/impl/listenbrainz/ListensSynchronizer.cpp b/src/libs/services/scrobbling/impl/listenbrainz/ListensSynchronizer.cpp index cf6d6a96..e08baab2 100644 --- a/src/libs/services/scrobbling/impl/listenbrainz/ListensSynchronizer.cpp +++ b/src/libs/services/scrobbling/impl/listenbrainz/ListensSynchronizer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #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);