123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #ifndef BOOST_ASIO_IMMEDIATE_HPP
- #define BOOST_ASIO_IMMEDIATE_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <boost/asio/associated_immediate_executor.hpp>
- #include <boost/asio/async_result.hpp>
- #include <boost/asio/dispatch.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace detail {
- template <typename Executor>
- class initiate_immediate
- {
- public:
- typedef Executor executor_type;
- explicit initiate_immediate(const Executor& ex)
- : ex_(ex)
- {
- }
- executor_type get_executor() const noexcept
- {
- return ex_;
- }
- template <typename CompletionHandler>
- void operator()(CompletionHandler&& handler) const
- {
- typename associated_immediate_executor<
- CompletionHandler, executor_type>::type ex =
- (get_associated_immediate_executor)(handler, ex_);
- (dispatch)(ex, static_cast<CompletionHandler&&>(handler));
- }
- private:
- Executor ex_;
- };
- }
- template <typename Executor,
- BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken
- = default_completion_token_t<Executor>>
- inline auto async_immediate(const Executor& ex,
- NullaryToken&& token = default_completion_token_t<Executor>(),
- constraint_t<
- (execution::is_executor<Executor>::value
- && can_require<Executor, execution::blocking_t::never_t>::value)
- || is_executor<Executor>::value
- > = 0)
- -> decltype(
- async_initiate<NullaryToken, void()>(
- declval<detail::initiate_immediate<Executor>>(), token))
- {
- return async_initiate<NullaryToken, void()>(
- detail::initiate_immediate<Executor>(ex), token);
- }
- template <typename ExecutionContext,
- BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) NullaryToken
- = default_completion_token_t<typename ExecutionContext::executor_type>>
- inline auto async_immediate(ExecutionContext& ctx,
- NullaryToken&& token = default_completion_token_t<
- typename ExecutionContext::executor_type>(),
- constraint_t<
- is_convertible<ExecutionContext&, execution_context&>::value
- > = 0)
- -> decltype(
- async_initiate<NullaryToken, void()>(
- declval<detail::initiate_immediate<
- typename ExecutionContext::executor_type>>(), token))
- {
- return async_initiate<NullaryToken, void()>(
- detail::initiate_immediate<
- typename ExecutionContext::executor_type>(
- ctx.get_executor()), token);
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|