summaryrefslogtreecommitdiff
path: root/boost/asio/io_context_strand.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/io_context_strand.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/io_context_strand.hpp')
-rw-r--r--boost/asio/io_context_strand.hpp92
1 files changed, 41 insertions, 51 deletions
diff --git a/boost/asio/io_context_strand.hpp b/boost/asio/io_context_strand.hpp
index 144e308a21..a9a9b522cd 100644
--- a/boost/asio/io_context_strand.hpp
+++ b/boost/asio/io_context_strand.hpp
@@ -2,7 +2,7 @@
// io_context_strand.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)
@@ -114,36 +114,6 @@ public:
{
}
-#if !defined(BOOST_ASIO_NO_DEPRECATED)
- /// (Deprecated: Use context().) Get the io_context associated with the
- /// strand.
- /**
- * This function may be used to obtain the io_context object that the strand
- * uses to dispatch handlers for asynchronous operations.
- *
- * @return A reference to the io_context object that the strand will use to
- * dispatch handlers. Ownership is not transferred to the caller.
- */
- boost::asio::io_context& get_io_context()
- {
- return service_.get_io_context();
- }
-
- /// (Deprecated: Use context().) Get the io_context associated with the
- /// strand.
- /**
- * This function may be used to obtain the io_context object that the strand
- * uses to dispatch handlers for asynchronous operations.
- *
- * @return A reference to the io_context object that the strand will use to
- * dispatch handlers. Ownership is not transferred to the caller.
- */
- boost::asio::io_context& get_io_service()
- {
- return service_.get_io_context();
- }
-#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
-
/// Obtain the underlying execution context.
boost::asio::io_context& context() const BOOST_ASIO_NOEXCEPT
{
@@ -216,16 +186,8 @@ public:
BOOST_ASIO_INITFN_RESULT_TYPE(LegacyCompletionHandler, void ())
dispatch(BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a LegacyCompletionHandler.
- BOOST_ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
- LegacyCompletionHandler, handler) type_check;
-
- async_completion<LegacyCompletionHandler, void ()> init(handler);
-
- service_.dispatch(impl_, init.completion_handler);
-
- return init.result.get();
+ return async_initiate<LegacyCompletionHandler, void ()>(
+ initiate_dispatch(), handler, this);
}
#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
@@ -271,16 +233,8 @@ public:
BOOST_ASIO_INITFN_RESULT_TYPE(LegacyCompletionHandler, void ())
post(BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler)
{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a LegacyCompletionHandler.
- BOOST_ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
- LegacyCompletionHandler, handler) type_check;
-
- async_completion<LegacyCompletionHandler, void ()> init(handler);
-
- service_.post(impl_, init.completion_handler);
-
- return init.result.get();
+ return async_initiate<LegacyCompletionHandler, void ()>(
+ initiate_post(), handler, this);
}
#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
@@ -372,6 +326,42 @@ public:
}
private:
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ struct initiate_dispatch
+ {
+ template <typename LegacyCompletionHandler>
+ void operator()(BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler,
+ strand* self) const
+ {
+ // If you get an error on the following line it means that your
+ // handler does not meet the documented type requirements for a
+ // LegacyCompletionHandler.
+ BOOST_ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
+ LegacyCompletionHandler, handler) type_check;
+
+ detail::non_const_lvalue<LegacyCompletionHandler> handler2(handler);
+ self->service_.dispatch(self->impl_, handler2.value);
+ }
+ };
+
+ struct initiate_post
+ {
+ template <typename LegacyCompletionHandler>
+ void operator()(BOOST_ASIO_MOVE_ARG(LegacyCompletionHandler) handler,
+ strand* self) const
+ {
+ // If you get an error on the following line it means that your
+ // handler does not meet the documented type requirements for a
+ // LegacyCompletionHandler.
+ BOOST_ASIO_LEGACY_COMPLETION_HANDLER_CHECK(
+ LegacyCompletionHandler, handler) type_check;
+
+ detail::non_const_lvalue<LegacyCompletionHandler> handler2(handler);
+ self->service_.post(self->impl_, handler2.value);
+ }
+ };
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
boost::asio::detail::strand_service& service_;
mutable boost::asio::detail::strand_service::implementation_type impl_;
};