Bläddra i källkod

支持ASIO 1.12.2以上版本

tags/v2.9.7
tearshark 5 år sedan
förälder
incheckning
47f4cd2685
1 ändrade filer med 28 tillägg och 28 borttagningar
  1. 28
    28
      librf/src/asio_task_1.12.0.inl

+ 28
- 28
librf/src/asio_task_1.12.0.inl Visa fil

__declspec(selectany) rf_task_t<> rf_task; __declspec(selectany) rf_task_t<> rf_task;
#endif #endif


namespace detail {
namespace librf {


template <typename Executor, typename T> template <typename Executor, typename T>
struct librf_awaitable_handler_base
struct awaitable_handler_base
{ {
public: public:
typedef T result_type; typedef T result_type;
typedef resumef::state_t<result_type> state_type; typedef resumef::state_t<result_type> state_type;


librf_awaitable_handler_base()
awaitable_handler_base()
: state_(resumef::make_counted<state_type>()) : state_(resumef::make_counted<state_type>())
{ {
} }


resumef::counted_ptr<state_type> state_; resumef::counted_ptr<state_type> state_;
librf_awaitable_handler_base(librf_awaitable_handler_base &&) = default;
librf_awaitable_handler_base(const librf_awaitable_handler_base &) = default;
librf_awaitable_handler_base & operator = (librf_awaitable_handler_base &&) = default;
librf_awaitable_handler_base & operator = (const librf_awaitable_handler_base &) = default;
awaitable_handler_base(awaitable_handler_base &&) = default;
awaitable_handler_base(const awaitable_handler_base &) = default;
awaitable_handler_base & operator = (awaitable_handler_base &&) = default;
awaitable_handler_base & operator = (const awaitable_handler_base &) = default;
}; };


template <typename, typename...> template <typename, typename...>
struct librf_promise_handler;
struct promise_handler;


template <typename Executor> template <typename Executor>
struct librf_promise_handler<Executor, void> : public librf_awaitable_handler_base<Executor, void>
struct promise_handler<Executor, void> : public awaitable_handler_base<Executor, void>
{ {
using librf_awaitable_handler_base<Executor, void>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, void>::awaitable_handler_base;


void operator()() const void operator()() const
{ {
}; };


template <typename Executor> template <typename Executor>
struct librf_promise_handler<Executor, asio::error_code> : public librf_awaitable_handler_base<Executor, void>
struct promise_handler<Executor, asio::error_code> : public awaitable_handler_base<Executor, void>
{ {
using librf_awaitable_handler_base<Executor, void>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, void>::awaitable_handler_base;


void operator()(const asio::error_code& ec) const void operator()(const asio::error_code& ec) const
{ {
}; };


template <typename Executor> template <typename Executor>
struct librf_promise_handler<Executor, std::exception_ptr> : public librf_awaitable_handler_base<Executor, void>
struct promise_handler<Executor, std::exception_ptr> : public awaitable_handler_base<Executor, void>
{ {
using librf_awaitable_handler_base<Executor, void>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, void>::awaitable_handler_base;


void operator()(std::exception_ptr ex) const void operator()(std::exception_ptr ex) const
{ {




template <typename Executor, typename T> template <typename Executor, typename T>
struct librf_promise_handler<Executor, T> : public librf_awaitable_handler_base<Executor, T>
struct promise_handler<Executor, T> : public awaitable_handler_base<Executor, T>
{ {
using librf_awaitable_handler_base<Executor, T>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, T>::awaitable_handler_base;


template <typename Arg> template <typename Arg>
void operator()(Arg&& arg) const void operator()(Arg&& arg) const
}; };


template <typename Executor, typename T> template <typename Executor, typename T>
struct librf_promise_handler<Executor, asio::error_code, T> : public librf_awaitable_handler_base<Executor, T>
struct promise_handler<Executor, asio::error_code, T> : public awaitable_handler_base<Executor, T>
{ {
using librf_awaitable_handler_base<Executor, T>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, T>::awaitable_handler_base;


template <typename Arg> template <typename Arg>
void operator()(const asio::error_code& ec, Arg&& arg) const void operator()(const asio::error_code& ec, Arg&& arg) const
}; };


template <typename Executor, typename T> template <typename Executor, typename T>
struct librf_promise_handler<Executor, std::exception_ptr, T> : public librf_awaitable_handler_base<Executor, T>
struct promise_handler<Executor, std::exception_ptr, T> : public awaitable_handler_base<Executor, T>
{ {
using librf_awaitable_handler_base<Executor, T>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, T>::awaitable_handler_base;


template <typename Arg> template <typename Arg>
void operator()(std::exception_ptr ex, Arg&& arg) const void operator()(std::exception_ptr ex, Arg&& arg) const




template <typename Executor, typename... Ts> template <typename Executor, typename... Ts>
struct librf_promise_handler : public librf_awaitable_handler_base<Executor, std::tuple<Ts...>>
struct promise_handler : public awaitable_handler_base<Executor, std::tuple<Ts...>>
{ {
using librf_awaitable_handler_base<Executor, std::tuple<Ts...>>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, std::tuple<Ts...>>::awaitable_handler_base;


template <typename... Args> template <typename... Args>
void operator()(Args&&... args) const void operator()(Args&&... args) const
}; };


template <typename Executor, typename... Ts> template <typename Executor, typename... Ts>
struct librf_promise_handler<Executor, asio::error_code, Ts...> : public librf_awaitable_handler_base<Executor, std::tuple<Ts...>>
struct promise_handler<Executor, asio::error_code, Ts...> : public awaitable_handler_base<Executor, std::tuple<Ts...>>
{ {
using librf_awaitable_handler_base<Executor, std::tuple<Ts...>>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, std::tuple<Ts...>>::awaitable_handler_base;


template <typename... Args> template <typename... Args>
void operator()(const asio::error_code& ec, Args&&... args) const void operator()(const asio::error_code& ec, Args&&... args) const
}; };


template <typename Executor, typename... Ts> template <typename Executor, typename... Ts>
struct librf_promise_handler<Executor, std::exception_ptr, Ts...> : public librf_awaitable_handler_base<Executor, std::tuple<Ts...>>
struct promise_handler<Executor, std::exception_ptr, Ts...> : public awaitable_handler_base<Executor, std::tuple<Ts...>>
{ {
using librf_awaitable_handler_base<Executor, std::tuple<Ts...>>::librf_awaitable_handler_base;
using awaitable_handler_base<Executor, std::tuple<Ts...>>::awaitable_handler_base;


template <typename... Args> template <typename... Args>
void operator()(std::exception_ptr ex, Args&&... args) const void operator()(std::exception_ptr ex, Args&&... args) const
} }
}; };


} // namespace detail
} // namespace librf


template <typename Executor, typename R, typename... Args> template <typename Executor, typename R, typename... Args>
class async_result<rf_task_t<Executor>, R(Args...)> class async_result<rf_task_t<Executor>, R(Args...)>
{ {
public: public:
typedef detail::librf_promise_handler<Executor, Args...> handler_type;
typedef librf::promise_handler<Executor, Args...> handler_type;
typedef typename handler_type::result_type result_type; typedef typename handler_type::result_type result_type;
typedef resumef::future_t<result_type> return_type; typedef resumef::future_t<result_type> return_type;



Laddar…
Avbryt
Spara