diff --git a/silkworm/infra/concurrency/awaitable_wait_for_all.hpp b/silkworm/infra/concurrency/awaitable_wait_for_all.hpp index 9933e159f1..183e942338 100644 --- a/silkworm/infra/concurrency/awaitable_wait_for_all.hpp +++ b/silkworm/infra/concurrency/awaitable_wait_for_all.hpp @@ -27,13 +27,13 @@ #include #include -#include #include #include #include #include #include +#include "co_spawn_sw.hpp" #include "parallel_group_utils.hpp" namespace silkworm::concurrency::awaitable_wait_for_all { @@ -71,8 +71,8 @@ awaitable operator&&( auto [order, ex0, ex1] = co_await make_parallel_group( - co_spawn(ex, std::move(t), deferred), - co_spawn(ex, std::move(u), deferred)) + co_spawn_sw(ex, std::move(t), deferred), + co_spawn_sw(ex, std::move(u), deferred)) .async_wait( wait_for_one_error(), use_awaitable_t{}); @@ -93,8 +93,8 @@ awaitable operator&&( auto [order, ex0, ex1, r1] = co_await make_parallel_group( - co_spawn(ex, std::move(t), deferred), - co_spawn(ex, detail::awaitable_wrap(std::move(u)), deferred)) + co_spawn_sw(ex, std::move(t), deferred), + co_spawn_sw(ex, detail::awaitable_wrap(std::move(u)), deferred)) .async_wait( wait_for_one_error(), use_awaitable_t{}); @@ -115,8 +115,8 @@ awaitable operator&&( auto [order, ex0, r0, ex1] = co_await make_parallel_group( - co_spawn(ex, detail::awaitable_wrap(std::move(t)), deferred), - co_spawn(ex, std::move(u), deferred)) + co_spawn_sw(ex, detail::awaitable_wrap(std::move(t)), deferred), + co_spawn_sw(ex, std::move(u), deferred)) .async_wait( wait_for_one_error(), use_awaitable_t{}); @@ -137,8 +137,8 @@ awaitable, Executor> operator&&( auto [order, ex0, r0, ex1, r1] = co_await make_parallel_group( - co_spawn(ex, detail::awaitable_wrap(std::move(t)), deferred), - co_spawn(ex, detail::awaitable_wrap(std::move(u)), deferred)) + co_spawn_sw(ex, detail::awaitable_wrap(std::move(t)), deferred), + co_spawn_sw(ex, detail::awaitable_wrap(std::move(u)), deferred)) .async_wait( wait_for_one_error(), use_awaitable_t{}); @@ -161,8 +161,8 @@ awaitable, Executor> operator&&( auto [order, ex0, r0, ex1, r1] = co_await make_parallel_group( - co_spawn(ex, detail::awaitable_wrap(std::move(t)), deferred), - co_spawn(ex, std::move(u), deferred)) + co_spawn_sw(ex, detail::awaitable_wrap(std::move(t)), deferred), + co_spawn_sw(ex, std::move(u), deferred)) .async_wait( wait_for_one_error(), use_awaitable_t{}); @@ -183,8 +183,8 @@ awaitable, Executor> operator&&( auto [order, ex0, r0, ex1, r1] = co_await make_parallel_group( - co_spawn(ex, detail::awaitable_wrap(std::move(t)), deferred), - co_spawn(ex, detail::awaitable_wrap(std::move(u)), deferred)) + co_spawn_sw(ex, detail::awaitable_wrap(std::move(t)), deferred), + co_spawn_sw(ex, detail::awaitable_wrap(std::move(u)), deferred)) .async_wait( wait_for_one_error(), use_awaitable_t{}); diff --git a/silkworm/infra/concurrency/awaitable_wait_for_one.hpp b/silkworm/infra/concurrency/awaitable_wait_for_one.hpp index 2542d4da2d..7c5e1e00d5 100644 --- a/silkworm/infra/concurrency/awaitable_wait_for_one.hpp +++ b/silkworm/infra/concurrency/awaitable_wait_for_one.hpp @@ -28,13 +28,14 @@ #include #include -#include #include #include #include #include #include +#include "co_spawn_sw.hpp" + namespace silkworm::concurrency::awaitable_wait_for_one { using boost::asio::experimental::wait_for_one; @@ -69,7 +70,8 @@ awaitable, Executor> operator||(awa auto ex = co_await this_coro::executor; auto [order, ex0, ex1] = - co_await make_parallel_group(co_spawn(ex, std::move(t), deferred), co_spawn(ex, std::move(u), deferred)) + co_await make_parallel_group(co_spawn_sw(ex, std::move(t), deferred), + co_spawn_sw(ex, std::move(u), deferred)) .async_wait(wait_for_one(), use_awaitable_t{}); if (order[0] == 0) { @@ -91,8 +93,8 @@ awaitable, Executor> operator||(awaitable{}); if (order[0] == 0) { @@ -116,8 +118,8 @@ awaitable, Executor> operator||(awaitable{}); if (order[0] == 0) { @@ -141,8 +143,8 @@ awaitable, Executor> operator||(awaitable t, awa auto ex = co_await this_coro::executor; auto [order, ex0, r0, ex1, r1] = - co_await make_parallel_group(co_spawn(ex, detail::awaitable_wrap(std::move(t)), deferred), - co_spawn(ex, detail::awaitable_wrap(std::move(u)), deferred)) + co_await make_parallel_group(co_spawn_sw(ex, detail::awaitable_wrap(std::move(t)), deferred), + co_spawn_sw(ex, detail::awaitable_wrap(std::move(u)), deferred)) .async_wait(wait_for_one(), use_awaitable_t{}); if (order[0] == 0) { @@ -165,8 +167,8 @@ awaitable, Executor> operator||(awaitable{}); using widen = detail::widen_variant; @@ -190,8 +192,8 @@ awaitable, Executor> operator||(awaitable{}); using widen = detail::widen_variant; diff --git a/silkworm/silkrpc/ethdb/kv/state_changes_stream.cpp b/silkworm/silkrpc/ethdb/kv/state_changes_stream.cpp index c5468c1fd4..a3fe0e152e 100644 --- a/silkworm/silkrpc/ethdb/kv/state_changes_stream.cpp +++ b/silkworm/silkrpc/ethdb/kv/state_changes_stream.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -45,7 +46,7 @@ StateChangesStream::StateChangesStream(ClientContext& context, remote::KV::StubI retry_timer_{scheduler_} {} std::future StateChangesStream::open() { - return boost::asio::co_spawn(scheduler_, run(), boost::asio::use_future); + return concurrency::co_spawn_sw(scheduler_, run(), boost::asio::use_future); } void StateChangesStream::close() {