// // experimental/channel_traits.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2024 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 ASIO_EXPERIMENTAL_CHANNEL_TRAITS_HPP #define ASIO_EXPERIMENTAL_CHANNEL_TRAITS_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include #include "asio/detail/type_traits.hpp" #include "asio/error.hpp" #include "asio/experimental/channel_error.hpp" #include "asio/detail/push_options.hpp" 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(asio::error_code); template static void invoke_receive_cancelled(F f) { const asio::error_code e = error::channel_cancelled; static_cast(f)(e); } typedef R receive_closed_signature(asio::error_code); template static void invoke_receive_closed(F f) { const asio::error_code e = error::channel_closed; static_cast(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(asio::error_code, Args...); template static void invoke_receive_cancelled(F f) { const asio::error_code e = error::channel_cancelled; static_cast(f)(e, decay_t()...); } typedef R receive_closed_signature(asio::error_code, Args...); template static void invoke_receive_closed(F f) { const asio::error_code e = error::channel_closed; static_cast(f)(e, decay_t()...); } }; 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); template static void invoke_receive_cancelled(F f) { const asio::error_code e = error::channel_cancelled; static_cast(f)( std::make_exception_ptr(asio::system_error(e))); } typedef R receive_closed_signature(std::exception_ptr); template static void invoke_receive_closed(F f) { const asio::error_code e = error::channel_closed; static_cast(f)( std::make_exception_ptr(asio::system_error(e))); } }; 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 asio::error_code e = error::channel_cancelled; static_cast(f)( std::make_exception_ptr(asio::system_error(e)), decay_t()...); } typedef R receive_closed_signature(std::exception_ptr, Args...); template static void invoke_receive_closed(F f) { const asio::error_code e = error::channel_closed; static_cast(f)( std::make_exception_ptr(asio::system_error(e)), decay_t()...); } }; template struct channel_traits { template struct rebind { typedef channel_traits other; }; template struct container { typedef std::deque type; }; typedef R receive_cancelled_signature(asio::error_code); template static void invoke_receive_cancelled(F f) { const asio::error_code e = error::channel_cancelled; static_cast(f)(e); } typedef R receive_closed_signature(asio::error_code); template static void invoke_receive_closed(F f) { const asio::error_code e = error::channel_closed; static_cast(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(asio::error_code); template static void invoke_receive_cancelled(F f) { const asio::error_code e = error::channel_cancelled; static_cast(f)(e); } typedef R receive_closed_signature(asio::error_code); template static void invoke_receive_closed(F f) { const asio::error_code e = error::channel_closed; static_cast(f)(e); } }; #endif // defined(GENERATING_DOCUMENTATION) } // namespace experimental } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_EXPERIMENTAL_CHANNEL_TRAITS_HPP