From: Casey Bodley Date: Thu, 9 Feb 2023 21:41:53 +0000 (-0500) Subject: common/async: completion uses free functions for defer/dispatch/post X-Git-Tag: v19.3.0~349^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=83e1ba13b00de15e8c225a1814523b60f456d450;p=ceph.git common/async: completion uses free functions for defer/dispatch/post Signed-off-by: Casey Bodley --- diff --git a/src/common/async/completion.h b/src/common/async/completion.h index a7dd7370f02..d8065934e01 100644 --- a/src/common/async/completion.h +++ b/src/common/async/completion.h @@ -17,7 +17,11 @@ #include +#include +#include +#include #include +#include #include "bind_handler.h" #include "forward_handler.h" @@ -183,33 +187,38 @@ class CompletionImpl final : public Completion { RebindTraits2::deallocate(alloc2, static_cast(p), 1); } - static auto bind_and_forward(Handler&& h, std::tuple&& args) { - return forward_handler(CompletionHandler{std::move(h), std::move(args)}); + static auto bind_and_forward(const Executor2& ex, Handler&& h, + std::tuple&& args) { + return forward_handler(CompletionHandler{ + boost::asio::bind_executor(ex, std::move(h)), std::move(args)}); } void destroy_defer(std::tuple&& args) override { auto w = std::move(work); + auto ex2 = w.second.get_executor(); RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler); - auto f = bind_and_forward(std::move(handler), std::move(args)); + auto f = bind_and_forward(ex2, std::move(handler), std::move(args)); RebindTraits2::destroy(alloc2, this); RebindTraits2::deallocate(alloc2, this, 1); - w.second.get_executor().defer(std::move(f), alloc2); + boost::asio::defer(boost::asio::bind_executor(ex2, std::move(f))); } void destroy_dispatch(std::tuple&& args) override { auto w = std::move(work); + auto ex2 = w.second.get_executor(); RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler); - auto f = bind_and_forward(std::move(handler), std::move(args)); + auto f = bind_and_forward(ex2, std::move(handler), std::move(args)); RebindTraits2::destroy(alloc2, this); RebindTraits2::deallocate(alloc2, this, 1); - w.second.get_executor().dispatch(std::move(f), alloc2); + boost::asio::dispatch(std::move(f)); } void destroy_post(std::tuple&& args) override { auto w = std::move(work); + auto ex2 = w.second.get_executor(); RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler); - auto f = bind_and_forward(std::move(handler), std::move(args)); + auto f = bind_and_forward(ex2, std::move(handler), std::move(args)); RebindTraits2::destroy(alloc2, this); RebindTraits2::deallocate(alloc2, this, 1); - w.second.get_executor().post(std::move(f), alloc2); + boost::asio::post(std::move(f)); } void destroy() override { RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler);