123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- #ifndef BOOST_ASIO_EXPERIMENTAL_USE_CORO_HPP
- #define BOOST_ASIO_EXPERIMENTAL_USE_CORO_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <memory>
- #include <boost/asio/deferred.hpp>
- #include <boost/asio/detail/source_location.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- class any_io_executor;
- namespace experimental {
- template <typename Allocator = std::allocator<void>>
- struct use_coro_t
- {
-
-
- typedef Allocator allocator_type;
-
- constexpr use_coro_t(
- allocator_type allocator = allocator_type{}
- #if defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
- # if defined(BOOST_ASIO_HAS_SOURCE_LOCATION)
- , boost::asio::detail::source_location location =
- boost::asio::detail::source_location::current()
- # endif
- #endif
- )
- : allocator_(allocator)
- #if defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
- # if defined(BOOST_ASIO_HAS_SOURCE_LOCATION)
- , file_name_(location.file_name()),
- line_(location.line()),
- function_name_(location.function_name())
- # else
- , file_name_(0),
- line_(0),
- function_name_(0)
- # endif
- #endif
- {
- }
-
- template <typename OtherAllocator>
- use_coro_t<OtherAllocator> rebind(const OtherAllocator& allocator) const
- {
- return use_future_t<OtherAllocator>(allocator);
- }
-
- allocator_type get_allocator() const
- {
- return allocator_;
- }
-
- constexpr use_coro_t(const char* file_name,
- int line, const char* function_name,
- allocator_type allocator = allocator_type{}) :
- #if defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
- file_name_(file_name),
- line_(line),
- function_name_(function_name),
- #endif
- allocator_(allocator)
- {
- #if !defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
- (void)file_name;
- (void)line;
- (void)function_name;
- #endif
- }
-
-
- template <typename InnerExecutor>
- struct executor_with_default : InnerExecutor
- {
-
- typedef use_coro_t default_completion_token_type;
-
- template <typename InnerExecutor1>
- executor_with_default(const InnerExecutor1& ex,
- constraint_t<
- conditional_t<
- !is_same<InnerExecutor1, executor_with_default>::value,
- is_convertible<InnerExecutor1, InnerExecutor>,
- false_type
- >::value
- > = 0) noexcept
- : InnerExecutor(ex)
- {
- }
- };
-
-
- template <typename T>
- using as_default_on_t = typename T::template rebind_executor<
- executor_with_default<typename T::executor_type>>::other;
-
-
- template <typename T>
- static typename decay_t<T>::template rebind_executor<
- executor_with_default<typename decay_t<T>::executor_type>
- >::other
- as_default_on(T&& object)
- {
- return typename decay_t<T>::template rebind_executor<
- executor_with_default<typename decay_t<T>::executor_type>
- >::other(static_cast<T&&>(object));
- }
- #if defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
- const char* file_name_;
- int line_;
- const char* function_name_;
- #endif
- private:
- Allocator allocator_;
- };
- #if defined(GENERATING_DOCUMENTATION)
- BOOST_ASIO_INLINE_VARIABLE constexpr use_coro_t<> use_coro;
- #else
- BOOST_ASIO_INLINE_VARIABLE constexpr use_coro_t<> use_coro(0, 0, 0);
- #endif
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #include <boost/asio/experimental/impl/use_coro.hpp>
- #include <boost/asio/experimental/coro.hpp>
- #endif
|