// // execution/executor.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_EXECUTION_EXECUTOR_HPP #define BOOST_ASIO_EXECUTION_EXECUTOR_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #include #include #if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_FREE_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) \ && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) # define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT 1 #endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_FREE_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) // && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) #include namespace boost { namespace asio { namespace execution { namespace detail { template struct is_executor_of_impl : false_type { }; template struct is_executor_of_impl::type, F>::value >::type, typename void_type< typename result_of::type&()>::type >::type, typename enable_if< is_constructible::type, F>::value >::type, typename enable_if< is_move_constructible::type>::value >::type, #if defined(BOOST_ASIO_HAS_NOEXCEPT) typename enable_if< is_nothrow_copy_constructible::value >::type, typename enable_if< is_nothrow_destructible::value >::type, #else // defined(BOOST_ASIO_HAS_NOEXCEPT) typename enable_if< is_copy_constructible::value >::type, typename enable_if< is_destructible::value >::type, #endif // defined(BOOST_ASIO_HAS_NOEXCEPT) typename enable_if< traits::equality_comparable::is_valid >::type, typename enable_if< traits::equality_comparable::is_noexcept >::type> : true_type { }; template struct executor_shape { typedef std::size_t type; }; template struct executor_shape::type> { typedef typename T::shape_type type; }; template struct executor_index { typedef Default type; }; template struct executor_index::type> { typedef typename T::index_type type; }; } // namespace detail /// The is_executor trait detects whether a type T satisfies the /// execution::executor concept. /** * Class template @c is_executor is a UnaryTypeTrait that is derived from @c * true_type if the type @c T meets the concept definition for an executor, * otherwise @c false_type. */ template struct is_executor : #if defined(GENERATING_DOCUMENTATION) integral_constant #else // defined(GENERATING_DOCUMENTATION) detail::is_executor_of_impl #endif // defined(GENERATING_DOCUMENTATION) { }; #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) template BOOST_ASIO_CONSTEXPR const bool is_executor_v = is_executor::value; #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) #if defined(BOOST_ASIO_HAS_CONCEPTS) template BOOST_ASIO_CONCEPT executor = is_executor::value; #define BOOST_ASIO_EXECUTION_EXECUTOR ::boost::asio::execution::executor #else // defined(BOOST_ASIO_HAS_CONCEPTS) #define BOOST_ASIO_EXECUTION_EXECUTOR typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) /// The is_executor_of trait detects whether a type T satisfies the /// execution::executor_of concept for some set of value arguments. /** * Class template @c is_executor_of is a type trait that is derived from @c * true_type if the type @c T meets the concept definition for an executor * that is invocable with a function object of type @c F, otherwise @c * false_type. */ template struct is_executor_of : #if defined(GENERATING_DOCUMENTATION) integral_constant #else // defined(GENERATING_DOCUMENTATION) integral_constant::value && detail::is_executor_of_impl::value > #endif // defined(GENERATING_DOCUMENTATION) { }; #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) template BOOST_ASIO_CONSTEXPR const bool is_executor_of_v = is_executor_of::value; #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) #if defined(BOOST_ASIO_HAS_CONCEPTS) template BOOST_ASIO_CONCEPT executor_of = is_executor_of::value; #define BOOST_ASIO_EXECUTION_EXECUTOR_OF(f) \ ::boost::asio::execution::executor_of #else // defined(BOOST_ASIO_HAS_CONCEPTS) #define BOOST_ASIO_EXECUTION_EXECUTOR_OF typename #endif // defined(BOOST_ASIO_HAS_CONCEPTS) /// The executor_shape trait detects the type used by an executor to represent /// the shape of a bulk operation. /** * Class template @c executor_shape is a type trait with a nested type alias * @c type whose type is @c T::shape_type if @c T::shape_type is valid, * otherwise @c std::size_t. */ template struct executor_shape #if !defined(GENERATING_DOCUMENTATION) : detail::executor_shape #endif // !defined(GENERATING_DOCUMENTATION) { #if defined(GENERATING_DOCUMENTATION) /// @c T::shape_type if @c T::shape_type is valid, otherwise @c std::size_t. typedef automatically_determined type; #endif // defined(GENERATING_DOCUMENTATION) }; #if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) template using executor_shape_t = typename executor_shape::type; #endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) /// The executor_index trait detects the type used by an executor to represent /// an index within a bulk operation. /** * Class template @c executor_index is a type trait with a nested type alias * @c type whose type is @c T::index_type if @c T::index_type is valid, * otherwise @c executor_shape_t. */ template struct executor_index #if !defined(GENERATING_DOCUMENTATION) : detail::executor_index::type> #endif // !defined(GENERATING_DOCUMENTATION) { #if defined(GENERATING_DOCUMENTATION) /// @c T::index_type if @c T::index_type is valid, otherwise /// @c executor_shape_t. typedef automatically_determined type; #endif // defined(GENERATING_DOCUMENTATION) }; #if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) template using executor_index_t = typename executor_index::type; #endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) } // namespace execution } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_EXECUTION_EXECUTOR_HPP