Browse Source

支持ASIO 1.12.2以上版本

tags/v2.9.7
tearshark 5 years ago
parent
commit
47f4cd2685
1 changed files with 28 additions and 28 deletions
  1. 28
    28
      librf/src/asio_task_1.12.0.inl

+ 28
- 28
librf/src/asio_task_1.12.0.inl View File

@@ -18,34 +18,34 @@ namespace asio {
__declspec(selectany) rf_task_t<> rf_task;
#endif

namespace detail {
namespace librf {

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

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

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...>
struct librf_promise_handler;
struct promise_handler;

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
{
@@ -54,9 +54,9 @@ namespace asio {
};

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
{
@@ -68,9 +68,9 @@ namespace asio {
};

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
{
@@ -84,9 +84,9 @@ namespace asio {


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>
void operator()(Arg&& arg) const
@@ -96,9 +96,9 @@ namespace asio {
};

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>
void operator()(const asio::error_code& ec, Arg&& arg) const
@@ -111,9 +111,9 @@ namespace asio {
};

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>
void operator()(std::exception_ptr ex, Arg&& arg) const
@@ -128,9 +128,9 @@ namespace asio {


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>
void operator()(Args&&... args) const
@@ -140,9 +140,9 @@ namespace asio {
};

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>
void operator()(const asio::error_code& ec, Args&&... args) const
@@ -155,9 +155,9 @@ namespace asio {
};

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>
void operator()(std::exception_ptr ex, Args&&... args) const
@@ -169,13 +169,13 @@ namespace asio {
}
};

} // namespace detail
} // namespace librf

template <typename Executor, typename R, typename... Args>
class async_result<rf_task_t<Executor>, R(Args...)>
{
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 resumef::future_t<result_type> return_type;


Loading…
Cancel
Save