mirror of
https://github.com/tearshark/librf.git
synced 2024-10-04 17:00:33 +08:00
支持ASIO 1.12.2以上版本
This commit is contained in:
parent
f4214e45e7
commit
47f4cd2685
@ -18,34 +18,34 @@ namespace asio {
|
|||||||
__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;
|
awaitable_handler_base(awaitable_handler_base &&) = default;
|
||||||
librf_awaitable_handler_base(const librf_awaitable_handler_base &) = default;
|
awaitable_handler_base(const awaitable_handler_base &) = default;
|
||||||
librf_awaitable_handler_base & operator = (librf_awaitable_handler_base &&) = default;
|
awaitable_handler_base & operator = (awaitable_handler_base &&) = default;
|
||||||
librf_awaitable_handler_base & operator = (const librf_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
|
||||||
{
|
{
|
||||||
@ -54,9 +54,9 @@ namespace asio {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -68,9 +68,9 @@ namespace asio {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -84,9 +84,9 @@ namespace asio {
|
|||||||
|
|
||||||
|
|
||||||
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
|
||||||
@ -96,9 +96,9 @@ namespace asio {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
@ -111,9 +111,9 @@ namespace asio {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
@ -128,9 +128,9 @@ namespace asio {
|
|||||||
|
|
||||||
|
|
||||||
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
|
||||||
@ -140,9 +140,9 @@ namespace asio {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
@ -155,9 +155,9 @@ namespace asio {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
@ -169,13 +169,13 @@ namespace asio {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // 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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user