// // experimental/channel_traits.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2022 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) // #ifndef BOOST_ASIO_EXPERIMENTAL_CHANNEL_TRAITS_HPP #define BOOST_ASIO_EXPERIMENTAL_CHANNEL_TRAITS_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #include #include #include namespace boost { namespace asio { namespace experimental { #if defined(GENERATING_DOCUMENTATION) template struct channel_traits { /// Rebind the traits to a new set of signatures. /** * This nested structure must have a single nested type @c other that * aliases a traits type with the specified set of signatures. */ template struct rebind { typedef user_defined other; }; /// Determine the container for the specified elements. /** * This nested structure must have a single nested type @c other that * aliases a container type for the specified element type. */ template struct container { typedef user_defined type; }; /// The signature of a channel cancellation notification. typedef void receive_cancelled_signature(...); /// Invoke the specified handler with a cancellation notification. template static void invoke_receive_cancelled(F f); /// The signature of a channel closed notification. typedef void receive_closed_signature(...); /// Invoke the specified handler with a closed notification. template static void invoke_receive_closed(F f); }; #else // defined(GENERATING_DOCUMENTATION) /// Traits used for customising channel behaviour. template struct channel_traits { template struct rebind { typedef channel_traits other; }; }; template struct channel_traits { template struct rebind { typedef channel_traits other; }; template struct container { typedef std::deque type; }; typedef R receive_cancelled_signature(boost::system::error_code, Args...); template static void invoke_receive_cancelled(F f) { const boost::system::error_code e = error::channel_cancelled; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)(e, typename decay::type()...); } typedef R receive_closed_signature(boost::system::error_code, Args...); template static void invoke_receive_closed(F f) { const boost::system::error_code e = error::channel_closed; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)(e, typename decay::type()...); } }; template struct channel_traits { template struct rebind { typedef channel_traits other; }; template struct container { typedef std::deque type; }; typedef R receive_cancelled_signature(std::exception_ptr, Args...); template static void invoke_receive_cancelled(F f) { const boost::system::error_code e = error::channel_cancelled; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)( std::make_exception_ptr(boost::system::system_error(e)), typename decay::type()...); } typedef R receive_closed_signature(std::exception_ptr, Args...); template static void invoke_receive_closed(F f) { const boost::system::error_code e = error::channel_closed; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)( std::make_exception_ptr(boost::system::system_error(e)), typename decay::type()...); } }; template struct channel_traits { template struct rebind { typedef channel_traits other; }; template struct container { typedef std::deque type; }; typedef R receive_cancelled_signature(boost::system::error_code); template static void invoke_receive_cancelled(F f) { const boost::system::error_code e = error::channel_cancelled; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)(e); } typedef R receive_closed_signature(boost::system::error_code); template static void invoke_receive_closed(F f) { const boost::system::error_code e = error::channel_closed; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)(e); } }; template struct channel_traits { template struct rebind { typedef channel_traits other; }; template struct container { typedef std::deque type; }; typedef R receive_cancelled_signature(boost::system::error_code); template static void invoke_receive_cancelled(F f) { const boost::system::error_code e = error::channel_cancelled; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)(e); } typedef R receive_closed_signature(boost::system::error_code); template static void invoke_receive_closed(F f) { const boost::system::error_code e = error::channel_closed; BOOST_ASIO_MOVE_OR_LVALUE(F)(f)(e); } }; #endif // defined(GENERATING_DOCUMENTATION) } // namespace experimental } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_EXPERIMENTAL_CHANNEL_TRAITS_HPP