// // any_io_executor.hpp // ~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2021 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_ANY_IO_EXECUTOR_HPP #define ASIO_ANY_IO_EXECUTOR_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) # include "asio/executor.hpp" #else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) # include "asio/execution.hpp" # include "asio/execution_context.hpp" #endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) #include "asio/detail/push_options.hpp" namespace asio { #if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) typedef executor any_io_executor; #else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) /// Polymorphic executor type for use with I/O objects. /** * The @c any_io_executor type is a polymorphic executor that supports the set * of properties required by I/O objects. It is defined as the * execution::any_executor class template parameterised as follows: * @code execution::any_executor< * execution::context_as_t, * execution::blocking_t::never_t, * execution::prefer_only, * execution::prefer_only, * execution::prefer_only, * execution::prefer_only, * execution::prefer_only * > @endcode */ class any_io_executor : #if defined(GENERATING_DOCUMENTATION) public execution::any_executor<...> #else // defined(GENERATING_DOCUMENTATION) public execution::any_executor< execution::context_as_t, execution::blocking_t::never_t, execution::prefer_only, execution::prefer_only, execution::prefer_only, execution::prefer_only, execution::prefer_only > #endif // defined(GENERATING_DOCUMENTATION) { public: #if !defined(GENERATING_DOCUMENTATION) typedef execution::any_executor< execution::context_as_t, execution::blocking_t::never_t, execution::prefer_only, execution::prefer_only, execution::prefer_only, execution::prefer_only, execution::prefer_only > base_type; typedef void supportable_properties_type( execution::context_as_t, execution::blocking_t::never_t, execution::prefer_only, execution::prefer_only, execution::prefer_only, execution::prefer_only, execution::prefer_only ); #endif // !defined(GENERATING_DOCUMENTATION) /// Default constructor. any_io_executor() ASIO_NOEXCEPT : base_type() { } /// Construct in an empty state. Equivalent effects to default constructor. any_io_executor(nullptr_t) ASIO_NOEXCEPT : base_type(nullptr_t()) { } /// Copy constructor. any_io_executor(const any_io_executor& e) ASIO_NOEXCEPT : base_type(static_cast(e)) { } #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move constructor. any_io_executor(any_io_executor&& e) ASIO_NOEXCEPT : base_type(static_cast(e)) { } #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct to point to the same target as another any_executor. #if defined(GENERATING_DOCUMENTATION) template any_io_executor(execution::any_executor e); #else // defined(GENERATING_DOCUMENTATION) template any_io_executor(OtherAnyExecutor e, typename constraint< conditional< !is_same::value && is_base_of::value, typename execution::detail::supportable_properties< 0, supportable_properties_type>::template is_valid_target, false_type >::type::value >::type = 0) : base_type(ASIO_MOVE_CAST(OtherAnyExecutor)(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Construct a polymorphic wrapper for the specified executor. #if defined(GENERATING_DOCUMENTATION) template any_io_executor(Executor e); #else // defined(GENERATING_DOCUMENTATION) template any_io_executor(Executor e, typename constraint< conditional< !is_same::value && !is_base_of::value, execution::detail::is_valid_target_executor< Executor, supportable_properties_type>, false_type >::type::value >::type = 0) : base_type(ASIO_MOVE_CAST(Executor)(e)) { } #endif // defined(GENERATING_DOCUMENTATION) /// Assignment operator. any_io_executor& operator=(const any_io_executor& e) ASIO_NOEXCEPT { base_type::operator=(static_cast(e)); return *this; } #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Move assignment operator. any_io_executor& operator=(any_io_executor&& e) ASIO_NOEXCEPT { base_type::operator=(static_cast(e)); return *this; } #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Assignment operator that sets the polymorphic wrapper to the empty state. any_io_executor& operator=(nullptr_t) { base_type::operator=(nullptr_t()); return *this; } /// Destructor. ~any_io_executor() { } /// Swap targets with another polymorphic wrapper. void swap(any_io_executor& other) ASIO_NOEXCEPT { static_cast(*this).swap(static_cast(other)); } /// Obtain a polymorphic wrapper with the specified property. /** * Do not call this function directly. It is intended for use with the * asio::require and asio::prefer customisation points. * * For example: * @code any_io_executor ex = ...; * auto ex2 = asio::require(ex, execution::blocking.possibly); @endcode */ template any_io_executor require(const Property& p, typename constraint< traits::require_member::is_valid >::type = 0) const { return static_cast(*this).require(p); } /// Obtain a polymorphic wrapper with the specified property. /** * Do not call this function directly. It is intended for use with the * asio::prefer customisation point. * * For example: * @code any_io_executor ex = ...; * auto ex2 = asio::prefer(ex, execution::blocking.possibly); @endcode */ template any_io_executor prefer(const Property& p, typename constraint< traits::prefer_member::is_valid >::type = 0) const { return static_cast(*this).prefer(p); } }; #if !defined(GENERATING_DOCUMENTATION) namespace traits { #if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) template <> struct equality_comparable { static const bool is_valid = true; static const bool is_noexcept = true; }; #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) #if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) template struct execute_member { static const bool is_valid = true; static const bool is_noexcept = false; typedef void result_type; }; #endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) #if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) template struct query_member : query_member { }; #endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) #if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) template struct require_member : require_member { typedef any_io_executor result_type; }; #endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) #if !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT) template struct prefer_member : prefer_member { typedef any_io_executor result_type; }; #endif // !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT) } // namespace traits #endif // !defined(GENERATING_DOCUMENTATION) #endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_ANY_IO_EXECUTOR_HPP