summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/detail/completion_handler.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/detail/completion_handler.hpp')
-rw-r--r--3rdparty/asio/include/asio/detail/completion_handler.hpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/3rdparty/asio/include/asio/detail/completion_handler.hpp b/3rdparty/asio/include/asio/detail/completion_handler.hpp
index e510dedfbcb..5c24fa42a8b 100644
--- a/3rdparty/asio/include/asio/detail/completion_handler.hpp
+++ b/3rdparty/asio/include/asio/detail/completion_handler.hpp
@@ -2,7 +2,7 @@
// detail/completion_handler.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -27,17 +27,17 @@
namespace asio {
namespace detail {
-template <typename Handler>
+template <typename Handler, typename IoExecutor>
class completion_handler : public operation
{
public:
ASIO_DEFINE_HANDLER_PTR(completion_handler);
- completion_handler(Handler& h)
+ completion_handler(Handler& h, const IoExecutor& io_ex)
: operation(&completion_handler::do_complete),
- handler_(ASIO_MOVE_CAST(Handler)(h))
+ handler_(ASIO_MOVE_CAST(Handler)(h)),
+ work_(handler_, io_ex)
{
- handler_work<Handler>::start(handler_);
}
static void do_complete(void* owner, operation* base,
@@ -47,10 +47,14 @@ public:
// Take ownership of the handler object.
completion_handler* h(static_cast<completion_handler*>(base));
ptr p = { asio::detail::addressof(h->handler_), h, h };
- handler_work<Handler> w(h->handler_);
ASIO_HANDLER_COMPLETION((*h));
+ // Take ownership of the operation's outstanding work.
+ handler_work<Handler, IoExecutor> w(
+ ASIO_MOVE_CAST2(handler_work<Handler, IoExecutor>)(
+ h->work_));
+
// Make a copy of the handler so that the memory can be deallocated before
// the upcall is made. Even if we're not about to make an upcall, a
// sub-object of the handler may be the true owner of the memory associated
@@ -73,6 +77,7 @@ public:
private:
Handler handler_;
+ handler_work<Handler, IoExecutor> work_;
};
} // namespace detail