summaryrefslogtreecommitdiff
path: root/boost/asio/detail/handler_work.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:22:41 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:22:41 +0900
commit3c1df2168531ad5580076ae08d529054689aeedd (patch)
tree941aff6f86393eecacddfec252a8508c7e8351c9 /boost/asio/detail/handler_work.hpp
parentd6a306e745acfee00e81ccaf3324a2a03516db41 (diff)
downloadboost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz
boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2
boost-3c1df2168531ad5580076ae08d529054689aeedd.zip
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/asio/detail/handler_work.hpp')
-rw-r--r--boost/asio/detail/handler_work.hpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/boost/asio/detail/handler_work.hpp b/boost/asio/detail/handler_work.hpp
index dbd1bb911a..06da376178 100644
--- a/boost/asio/detail/handler_work.hpp
+++ b/boost/asio/detail/handler_work.hpp
@@ -2,7 +2,7 @@
// detail/handler_work.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 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)
@@ -28,24 +28,41 @@ namespace detail {
// A helper class template to allow completion handlers to be dispatched
// through either the new executors framework or the old invocaton hook. The
// primary template uses the new executors framework.
-template <typename Handler, typename Executor
- = typename associated_executor<Handler>::type>
+template <typename Handler,
+ typename IoExecutor = system_executor, typename HandlerExecutor
+ = typename associated_executor<Handler, IoExecutor>::type>
class handler_work
{
public:
explicit handler_work(Handler& handler) BOOST_ASIO_NOEXCEPT
- : executor_(associated_executor<Handler>::get(handler))
+ : io_executor_(),
+ executor_(boost::asio::get_associated_executor(handler, io_executor_))
+ {
+ }
+
+ handler_work(Handler& handler, const IoExecutor& io_ex) BOOST_ASIO_NOEXCEPT
+ : io_executor_(io_ex),
+ executor_(boost::asio::get_associated_executor(handler, io_executor_))
{
}
static void start(Handler& handler) BOOST_ASIO_NOEXCEPT
{
- Executor ex(associated_executor<Handler>::get(handler));
+ HandlerExecutor ex(boost::asio::get_associated_executor(handler));
+ ex.on_work_started();
+ }
+
+ static void start(Handler& handler,
+ const IoExecutor& io_ex) BOOST_ASIO_NOEXCEPT
+ {
+ HandlerExecutor ex(boost::asio::get_associated_executor(handler, io_ex));
ex.on_work_started();
+ io_ex.on_work_started();
}
~handler_work()
{
+ io_executor_.on_work_finished();
executor_.on_work_finished();
}
@@ -53,7 +70,7 @@ public:
void complete(Function& function, Handler& handler)
{
executor_.dispatch(BOOST_ASIO_MOVE_CAST(Function)(function),
- associated_allocator<Handler>::get(handler));
+ boost::asio::get_associated_allocator(handler));
}
private:
@@ -61,7 +78,8 @@ private:
handler_work(const handler_work&);
handler_work& operator=(const handler_work&);
- typename associated_executor<Handler>::type executor_;
+ IoExecutor io_executor_;
+ HandlerExecutor executor_;
};
// This specialisation dispatches a handler through the old invocation hook.
@@ -69,7 +87,7 @@ private:
// system_executor will dispatch through the hook anyway. However, by doing
// this we avoid an extra copy of the handler.
template <typename Handler>
-class handler_work<Handler, system_executor>
+class handler_work<Handler, system_executor, system_executor>
{
public:
explicit handler_work(Handler&) BOOST_ASIO_NOEXCEPT {}