123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #ifndef BOOST_ASIO_ASSOCIATED_EXECUTOR_HPP
- #define BOOST_ASIO_ASSOCIATED_EXECUTOR_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <boost/asio/detail/type_traits.hpp>
- #include <boost/asio/execution/executor.hpp>
- #include <boost/asio/is_executor.hpp>
- #include <boost/asio/system_executor.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace detail {
- template <typename T, typename E, typename = void>
- struct associated_executor_impl
- {
- typedef void asio_associated_executor_is_unspecialised;
- typedef E type;
- static type get(const T&, const E& e = E()) BOOST_ASIO_NOEXCEPT
- {
- return e;
- }
- };
- template <typename T, typename E>
- struct associated_executor_impl<T, E,
- typename void_type<typename T::executor_type>::type>
- {
- typedef typename T::executor_type type;
- static type get(const T& t, const E& = E()) BOOST_ASIO_NOEXCEPT
- {
- return t.get_executor();
- }
- };
- }
- template <typename T, typename Executor = system_executor>
- struct associated_executor
- #if !defined(GENERATING_DOCUMENTATION)
- : detail::associated_executor_impl<T, Executor>
- #endif
- {
- #if defined(GENERATING_DOCUMENTATION)
-
-
- typedef see_below type;
-
-
- static type get(const T& t,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT;
- #endif
- };
- template <typename T>
- inline typename associated_executor<T>::type
- get_associated_executor(const T& t) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<T>::get(t);
- }
- template <typename T, typename Executor>
- inline typename associated_executor<T, Executor>::type
- get_associated_executor(const T& t, const Executor& ex,
- typename constraint<
- is_executor<Executor>::value || execution::is_executor<Executor>::value
- >::type = 0) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<T, Executor>::get(t, ex);
- }
- template <typename T, typename ExecutionContext>
- inline typename associated_executor<T,
- typename ExecutionContext::executor_type>::type
- get_associated_executor(const T& t, ExecutionContext& ctx,
- typename constraint<is_convertible<ExecutionContext&,
- execution_context&>::value>::type = 0) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<T,
- typename ExecutionContext::executor_type>::get(t, ctx.get_executor());
- }
- #if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
- template <typename T, typename Executor = system_executor>
- using associated_executor_t = typename associated_executor<T, Executor>::type;
- #endif
- namespace detail {
- template <typename T, typename E, typename = void>
- struct associated_executor_forwarding_base
- {
- };
- template <typename T, typename E>
- struct associated_executor_forwarding_base<T, E,
- typename enable_if<
- is_same<
- typename associated_executor<T,
- E>::asio_associated_executor_is_unspecialised,
- void
- >::value
- >::type>
- {
- typedef void asio_associated_executor_is_unspecialised;
- };
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|