diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/wrapped_handler.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/detail/wrapped_handler.hpp | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/wrapped_handler.hpp b/3rdParty/Boost/src/boost/asio/detail/wrapped_handler.hpp index b326847..d82da22 100644 --- a/3rdParty/Boost/src/boost/asio/detail/wrapped_handler.hpp +++ b/3rdParty/Boost/src/boost/asio/detail/wrapped_handler.hpp @@ -2,7 +2,7 @@ // detail/wrapped_handler.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 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) @@ -31,12 +31,26 @@ class wrapped_handler public: typedef void result_type; - wrapped_handler(Dispatcher dispatcher, Handler handler) + wrapped_handler(Dispatcher dispatcher, Handler& handler) : dispatcher_(dispatcher), - handler_(handler) + handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)) { } +#if defined(BOOST_ASIO_HAS_MOVE) + wrapped_handler(const wrapped_handler& other) + : dispatcher_(other.dispatcher_), + handler_(other.handler_) + { + } + + wrapped_handler(wrapped_handler&& other) + : dispatcher_(other.dispatcher_), + handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)) + { + } +#endif // defined(BOOST_ASIO_HAS_MOVE) + void operator()() { dispatcher_.dispatch(handler_); @@ -126,11 +140,31 @@ template <typename Handler, typename Context> class rewrapped_handler { public: + explicit rewrapped_handler(Handler& handler, const Context& context) + : context_(context), + handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)) + { + } + explicit rewrapped_handler(const Handler& handler, const Context& context) - : handler_(handler), - context_(context) + : context_(context), + handler_(handler) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) + rewrapped_handler(const rewrapped_handler& other) + : context_(other.context_), + handler_(other.handler_) + { + } + + rewrapped_handler(rewrapped_handler&& other) + : context_(BOOST_ASIO_MOVE_CAST(Context)(other.context_)), + handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)) { } +#endif // defined(BOOST_ASIO_HAS_MOVE) void operator()() { @@ -143,8 +177,8 @@ public: } //private: - Handler handler_; Context context_; + Handler handler_; }; template <typename Dispatcher, typename Handler> @@ -164,6 +198,15 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size, } template <typename Function, typename Dispatcher, typename Handler> +inline void asio_handler_invoke(Function& function, + wrapped_handler<Dispatcher, Handler>* this_handler) +{ + this_handler->dispatcher_.dispatch( + rewrapped_handler<Function, Handler>( + function, this_handler->handler_)); +} + +template <typename Function, typename Dispatcher, typename Handler> inline void asio_handler_invoke(const Function& function, wrapped_handler<Dispatcher, Handler>* this_handler) { @@ -189,6 +232,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size, } template <typename Function, typename Handler, typename Context> +inline void asio_handler_invoke(Function& function, + rewrapped_handler<Handler, Context>* this_handler) +{ + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->context_); +} + +template <typename Function, typename Handler, typename Context> inline void asio_handler_invoke(const Function& function, rewrapped_handler<Handler, Context>* this_handler) { |