]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/async: completion uses free functions for defer/dispatch/post
authorCasey Bodley <cbodley@redhat.com>
Thu, 9 Feb 2023 21:41:53 +0000 (16:41 -0500)
committerAdam Emerson <aemerson@redhat.com>
Thu, 14 Sep 2023 21:14:30 +0000 (17:14 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/common/async/completion.h

index f2c9f112dc55071c2c1aad8356b99ea56f6d29ef..3ab2e340ead04c2eff30ff8be8e17d2e178b9fc7 100644 (file)
@@ -181,33 +181,38 @@ class CompletionImpl final : public Completion<void(Args...), T> {
     RebindTraits2::deallocate(alloc2, static_cast<CompletionImpl*>(p), 1);
   }
 
-  static auto bind_and_forward(Handler&& h, std::tuple<Args...>&& args) {
-    return forward_handler(CompletionHandler{std::move(h), std::move(args)});
+  static auto bind_and_forward(const Executor2& ex, Handler&& h,
+                               std::tuple<Args...>&& args) {
+    return forward_handler(CompletionHandler{
+        boost::asio::bind_executor(ex, std::move(h)), std::move(args)});
   }
 
   void destroy_defer(std::tuple<Args...>&& 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...>&& 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...>&& 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);