Enable move-only handlers.
All async operations and executor operations support move-only handlers. However, the io_service::post(), io_service::dispatch(), io_service::strand::post() and io_service::strand::dispatch() functions still require copyable handlers.
This commit is contained in:
parent
74e12e51ba
commit
d25fa4e5dd
@ -22,6 +22,7 @@
|
||||
#include "asio/detail/throw_error.hpp"
|
||||
#include "asio/detail/type_traits.hpp"
|
||||
#include "asio/error.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/socket_base.hpp"
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
@ -747,7 +748,7 @@ public:
|
||||
async_completion<ConnectHandler,
|
||||
void (asio::error_code)> init(handler);
|
||||
|
||||
this->get_service().get_io_service().post(
|
||||
asio::post(this->get_executor(),
|
||||
asio::detail::bind_handler(
|
||||
ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(
|
||||
ConnectHandler, void (asio::error_code)))(
|
||||
|
@ -31,8 +31,8 @@ template <typename Handler, typename Arg1>
|
||||
class binder1
|
||||
{
|
||||
public:
|
||||
binder1(const Handler& handler, const Arg1& arg1)
|
||||
: handler_(handler),
|
||||
binder1(int, ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1)
|
||||
{
|
||||
}
|
||||
@ -43,6 +43,20 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
binder1(const binder1& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_)
|
||||
{
|
||||
}
|
||||
|
||||
binder1(binder1&& other)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(ASIO_MOVE_CAST(Arg1)(other.arg1_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_));
|
||||
@ -99,18 +113,20 @@ inline void asio_handler_invoke(const Function& function,
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline binder1<Handler, Arg1> bind_handler(Handler handler,
|
||||
const Arg1& arg1)
|
||||
inline binder1<Handler, Arg1> bind_handler(
|
||||
ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1)
|
||||
{
|
||||
return binder1<Handler, Arg1>(handler, arg1);
|
||||
return binder1<Handler, Arg1>(0,
|
||||
ASIO_MOVE_CAST(Handler)(handler), arg1);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
class binder2
|
||||
{
|
||||
public:
|
||||
binder2(const Handler& handler, const Arg1& arg1, const Arg2& arg2)
|
||||
: handler_(handler),
|
||||
binder2(int, ASIO_MOVE_ARG(Handler) handler,
|
||||
const Arg1& arg1, const Arg2& arg2)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2)
|
||||
{
|
||||
@ -123,6 +139,22 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
binder2(const binder2& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_),
|
||||
arg2_(other.arg2_)
|
||||
{
|
||||
}
|
||||
|
||||
binder2(binder2&& other)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(ASIO_MOVE_CAST(Arg1)(other.arg1_)),
|
||||
arg2_(ASIO_MOVE_CAST(Arg2)(other.arg2_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
@ -181,306 +213,11 @@ inline void asio_handler_invoke(const Function& function,
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline binder2<Handler, Arg1, Arg2> bind_handler(Handler handler,
|
||||
const Arg1& arg1, const Arg2& arg2)
|
||||
inline binder2<Handler, Arg1, Arg2> bind_handler(
|
||||
ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1, const Arg2& arg2)
|
||||
{
|
||||
return binder2<Handler, Arg1, Arg2>(handler, arg1, arg2);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
class binder3
|
||||
{
|
||||
public:
|
||||
binder3(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3)
|
||||
: handler_(handler),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3)
|
||||
{
|
||||
}
|
||||
|
||||
binder3(Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_),
|
||||
static_cast<const Arg3&>(arg3_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_, arg3_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
Arg3 arg3_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
return asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
return asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline binder3<Handler, Arg1, Arg2, Arg3> bind_handler(Handler handler,
|
||||
const Arg1& arg1, const Arg2& arg2, const Arg3& arg3)
|
||||
{
|
||||
return binder3<Handler, Arg1, Arg2, Arg3>(handler, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4>
|
||||
class binder4
|
||||
{
|
||||
public:
|
||||
binder4(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4)
|
||||
: handler_(handler),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4)
|
||||
{
|
||||
}
|
||||
|
||||
binder4(Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_),
|
||||
static_cast<const Arg3&>(arg3_),
|
||||
static_cast<const Arg4&>(arg4_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_, arg3_, arg4_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
Arg3 arg3_;
|
||||
Arg4 arg4_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
return asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
return asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4>
|
||||
inline binder4<Handler, Arg1, Arg2, Arg3, Arg4> bind_handler(
|
||||
Handler handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4)
|
||||
{
|
||||
return binder4<Handler, Arg1, Arg2, Arg3, Arg4>(handler, arg1, arg2, arg3,
|
||||
arg4);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5>
|
||||
class binder5
|
||||
{
|
||||
public:
|
||||
binder5(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
: handler_(handler),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4),
|
||||
arg5_(arg5)
|
||||
{
|
||||
}
|
||||
|
||||
binder5(Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4),
|
||||
arg5_(arg5)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_),
|
||||
static_cast<const Arg3&>(arg3_),
|
||||
static_cast<const Arg4&>(arg4_),
|
||||
static_cast<const Arg5&>(arg5_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_, arg3_, arg4_, arg5_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
Arg3 arg3_;
|
||||
Arg4 arg4_;
|
||||
Arg5 arg5_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
return asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
return asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5>
|
||||
inline binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5> bind_handler(
|
||||
Handler handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
{
|
||||
return binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>(handler, arg1, arg2,
|
||||
arg3, arg4, arg5);
|
||||
return binder2<Handler, Arg1, Arg2>(0,
|
||||
ASIO_MOVE_CAST(Handler)(handler), arg1, arg2);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@ -509,49 +246,6 @@ struct associated_allocator<detail::binder2<Handler, Arg1, Arg2>, Allocator>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Allocator>
|
||||
struct associated_allocator<detail::binder3<Handler, Arg1, Arg2, Arg3>,
|
||||
Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const detail::binder3<Handler, Arg1, Arg2, Arg3>& h,
|
||||
const Allocator& a = Allocator()) ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Allocator>
|
||||
struct associated_allocator<detail::binder4<Handler, Arg1, Arg2, Arg3, Arg4>,
|
||||
Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const detail::binder4<Handler, Arg1, Arg2, Arg3, Arg4>& h,
|
||||
const Allocator& a = Allocator()) ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5, typename Allocator>
|
||||
struct associated_allocator<
|
||||
detail::binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>, Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(
|
||||
const detail::binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>& h,
|
||||
const Allocator& a = Allocator()) ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Executor>
|
||||
struct associated_executor<detail::binder1<Handler, Arg1>, Executor>
|
||||
{
|
||||
@ -576,49 +270,6 @@ struct associated_executor<detail::binder2<Handler, Arg1, Arg2>, Executor>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Executor>
|
||||
struct associated_executor<detail::binder3<Handler, Arg1, Arg2, Arg3>,
|
||||
Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const detail::binder3<Handler, Arg1, Arg2, Arg3>& h,
|
||||
const Executor& ex = Executor()) ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Executor>
|
||||
struct associated_executor<detail::binder4<Handler, Arg1, Arg2, Arg3, Arg4>,
|
||||
Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const detail::binder4<Handler, Arg1, Arg2, Arg3, Arg4>& h,
|
||||
const Executor& ex = Executor()) ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5, typename Executor>
|
||||
struct associated_executor<
|
||||
detail::binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>, Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(
|
||||
const detail::binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>& h,
|
||||
const Executor& ex = Executor()) ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
@ -71,19 +71,19 @@ namespace detail {
|
||||
# if defined(ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT)
|
||||
|
||||
template <typename Handler>
|
||||
auto zero_arg_handler_test(Handler h, void*)
|
||||
auto zero_arg_copyable_handler_test(Handler h, void*)
|
||||
-> decltype(
|
||||
sizeof(Handler(static_cast<const Handler&>(h))),
|
||||
((h)()),
|
||||
char(0));
|
||||
|
||||
template <typename Handler>
|
||||
char (&zero_arg_handler_test(Handler, ...))[2];
|
||||
char (&zero_arg_copyable_handler_test(Handler, ...))[2];
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
auto one_arg_handler_test(Handler h, Arg1* a1)
|
||||
-> decltype(
|
||||
sizeof(Handler(static_cast<const Handler&>(h))),
|
||||
sizeof(Handler(ASIO_MOVE_CAST(Handler)(h))),
|
||||
((h)(*a1)),
|
||||
char(0));
|
||||
|
||||
@ -93,7 +93,7 @@ char (&one_arg_handler_test(Handler h, ...))[2];
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
auto two_arg_handler_test(Handler h, Arg1* a1, Arg2* a2)
|
||||
-> decltype(
|
||||
sizeof(Handler(static_cast<const Handler&>(h))),
|
||||
sizeof(Handler(ASIO_MOVE_CAST(Handler)(h))),
|
||||
((h)(*a1, *a2)),
|
||||
char(0));
|
||||
|
||||
@ -113,6 +113,13 @@ template <typename T> T& lvref();
|
||||
template <typename T> T& lvref(T);
|
||||
template <typename T> const T& clvref();
|
||||
template <typename T> const T& clvref(T);
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
template <typename T> T rvref();
|
||||
template <typename T> T rvref(T);
|
||||
#else // defined(ASIO_HAS_MOVE)
|
||||
template <typename T> const T& rvref();
|
||||
template <typename T> const T& rvref(T);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
template <typename T> char argbyv(T);
|
||||
|
||||
template <int>
|
||||
@ -127,7 +134,7 @@ struct handler_type_requirements
|
||||
void()) asio_true_handler_type; \
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::zero_arg_handler_test( \
|
||||
sizeof(asio::detail::zero_arg_copyable_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio_true_handler_type>(), 0)) == 1, \
|
||||
"CompletionHandler type requirements not met") \
|
||||
@ -151,7 +158,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::two_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0), \
|
||||
static_cast<const std::size_t*>(0))) == 1, \
|
||||
@ -160,7 +167,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -169,7 +176,6 @@ struct handler_type_requirements
|
||||
asio::detail::lvref<const std::size_t>()), \
|
||||
char(0))> ASIO_UNUSED_TYPEDEF
|
||||
|
||||
|
||||
#define ASIO_WRITE_HANDLER_CHECK( \
|
||||
handler_type, handler) \
|
||||
\
|
||||
@ -179,7 +185,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::two_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0), \
|
||||
static_cast<const std::size_t*>(0))) == 1, \
|
||||
@ -188,7 +194,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -206,7 +212,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::one_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0))) == 1, \
|
||||
"AcceptHandler type requirements not met") \
|
||||
@ -214,7 +220,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -231,7 +237,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::one_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0))) == 1, \
|
||||
"ConnectHandler type requirements not met") \
|
||||
@ -239,7 +245,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -256,7 +262,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::two_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0), \
|
||||
static_cast<const iter_type*>(0))) == 1, \
|
||||
@ -265,7 +271,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -283,7 +289,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::two_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0), \
|
||||
static_cast<const iter_type*>(0))) == 1, \
|
||||
@ -292,7 +298,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -310,7 +316,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::one_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0))) == 1, \
|
||||
"WaitHandler type requirements not met") \
|
||||
@ -318,7 +324,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -335,7 +341,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::two_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0), \
|
||||
static_cast<const int*>(0))) == 1, \
|
||||
@ -344,7 +350,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -362,7 +368,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::one_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0))) == 1, \
|
||||
"HandshakeHandler type requirements not met") \
|
||||
@ -370,7 +376,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -387,7 +393,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::two_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0), \
|
||||
static_cast<const std::size_t*>(0))) == 1, \
|
||||
@ -396,7 +402,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
@ -414,7 +420,7 @@ struct handler_type_requirements
|
||||
\
|
||||
ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
|
||||
sizeof(asio::detail::one_arg_handler_test( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>(), \
|
||||
static_cast<const asio::error_code*>(0))) == 1, \
|
||||
"ShutdownHandler type requirements not met") \
|
||||
@ -422,7 +428,7 @@ struct handler_type_requirements
|
||||
typedef asio::detail::handler_type_requirements< \
|
||||
sizeof( \
|
||||
asio::detail::argbyv( \
|
||||
asio::detail::clvref< \
|
||||
asio::detail::rvref< \
|
||||
asio_true_handler_type>())) + \
|
||||
sizeof( \
|
||||
asio::detail::lvref< \
|
||||
|
@ -35,6 +35,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
work_dispatcher(const work_dispatcher& other)
|
||||
: work_(other.work_),
|
||||
handler_(other.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
work_dispatcher(work_dispatcher&& other)
|
||||
: work_(ASIO_MOVE_CAST(executor_work<
|
||||
typename associated_executor<Handler>::type>)(other.work_)),
|
||||
handler_(ASIO_MOVE_CAST(Handler)(other.handler_))
|
||||
{
|
||||
}
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
typename associated_executor<Handler>::type ex(work_.get_executor());
|
||||
|
@ -232,7 +232,7 @@ namespace detail
|
||||
const MutableBufferSequence& buffers, ReadHandler& handler)
|
||||
: storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(handler)
|
||||
handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace detail
|
||||
buffered_flush_handler(detail::buffered_stream_storage& storage,
|
||||
WriteHandler& handler)
|
||||
: storage_(storage),
|
||||
handler_(handler)
|
||||
handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ namespace detail
|
||||
const ConstBufferSequence& buffers, WriteHandler& handler)
|
||||
: storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(handler)
|
||||
handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,12 @@ struct concrete_handler
|
||||
void operator()(Arg1, Arg2)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
concrete_handler(concrete_handler&&) {}
|
||||
private:
|
||||
concrete_handler(const concrete_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
} // namespace archetypes
|
||||
|
@ -28,23 +28,44 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ip_icmp_socket_compile test
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// The following test checks that all public member functions on the class
|
||||
// ip::icmp::socket compile and link correctly. Runtime failures are ignored.
|
||||
|
||||
namespace ip_icmp_socket_compile {
|
||||
|
||||
void connect_handler(const asio::error_code&)
|
||||
struct connect_handler
|
||||
{
|
||||
}
|
||||
connect_handler() {}
|
||||
void operator()(const asio::error_code&) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
connect_handler(connect_handler&&) {}
|
||||
private:
|
||||
connect_handler(const connect_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void send_handler(const asio::error_code&, std::size_t)
|
||||
struct send_handler
|
||||
{
|
||||
}
|
||||
send_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
send_handler(send_handler&&) {}
|
||||
private:
|
||||
send_handler(const send_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void receive_handler(const asio::error_code&, std::size_t)
|
||||
struct receive_handler
|
||||
{
|
||||
}
|
||||
receive_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receive_handler(receive_handler&&) {}
|
||||
private:
|
||||
receive_handler(const receive_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -151,9 +172,9 @@ void test()
|
||||
socket1.connect(ip::icmp::endpoint(ip::icmp::v6(), 0), ec);
|
||||
|
||||
socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0),
|
||||
&connect_handler);
|
||||
connect_handler());
|
||||
socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0),
|
||||
&connect_handler);
|
||||
connect_handler());
|
||||
int i1 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
|
||||
(void)i1;
|
||||
int i2 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
|
||||
@ -207,12 +228,12 @@ void test()
|
||||
socket1.send(buffer(const_char_buffer), in_flags, ec);
|
||||
socket1.send(null_buffers(), in_flags, ec);
|
||||
|
||||
socket1.async_send(buffer(mutable_char_buffer), &send_handler);
|
||||
socket1.async_send(buffer(const_char_buffer), &send_handler);
|
||||
socket1.async_send(null_buffers(), &send_handler);
|
||||
socket1.async_send(buffer(mutable_char_buffer), in_flags, &send_handler);
|
||||
socket1.async_send(buffer(const_char_buffer), in_flags, &send_handler);
|
||||
socket1.async_send(null_buffers(), in_flags, &send_handler);
|
||||
socket1.async_send(buffer(mutable_char_buffer), send_handler());
|
||||
socket1.async_send(buffer(const_char_buffer), send_handler());
|
||||
socket1.async_send(null_buffers(), send_handler());
|
||||
socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler());
|
||||
socket1.async_send(buffer(const_char_buffer), in_flags, send_handler());
|
||||
socket1.async_send(null_buffers(), in_flags, send_handler());
|
||||
int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
|
||||
(void)i3;
|
||||
int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
|
||||
@ -264,29 +285,29 @@ void test()
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
|
||||
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, &send_handler);
|
||||
ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, send_handler());
|
||||
int i9 = socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
|
||||
(void)i9;
|
||||
@ -331,11 +352,11 @@ void test()
|
||||
socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
|
||||
socket1.receive(null_buffers(), in_flags, ec);
|
||||
|
||||
socket1.async_receive(buffer(mutable_char_buffer), &receive_handler);
|
||||
socket1.async_receive(null_buffers(), &receive_handler);
|
||||
socket1.async_receive(buffer(mutable_char_buffer), receive_handler());
|
||||
socket1.async_receive(null_buffers(), receive_handler());
|
||||
socket1.async_receive(buffer(mutable_char_buffer), in_flags,
|
||||
&receive_handler);
|
||||
socket1.async_receive(null_buffers(), in_flags, &receive_handler);
|
||||
receive_handler());
|
||||
socket1.async_receive(null_buffers(), in_flags, receive_handler());
|
||||
int i21 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
|
||||
(void)i21;
|
||||
int i22 = socket1.async_receive(null_buffers(), lazy);
|
||||
@ -355,13 +376,13 @@ void test()
|
||||
socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
|
||||
|
||||
socket1.async_receive_from(buffer(mutable_char_buffer),
|
||||
endpoint, &receive_handler);
|
||||
endpoint, receive_handler());
|
||||
socket1.async_receive_from(null_buffers(),
|
||||
endpoint, &receive_handler);
|
||||
endpoint, receive_handler());
|
||||
socket1.async_receive_from(buffer(mutable_char_buffer),
|
||||
endpoint, in_flags, &receive_handler);
|
||||
endpoint, in_flags, receive_handler());
|
||||
socket1.async_receive_from(null_buffers(),
|
||||
endpoint, in_flags, &receive_handler);
|
||||
endpoint, in_flags, receive_handler());
|
||||
int i25 = socket1.async_receive_from(buffer(mutable_char_buffer),
|
||||
endpoint, lazy);
|
||||
(void)i25;
|
||||
|
@ -137,25 +137,60 @@ void test()
|
||||
|
||||
namespace ip_tcp_socket_compile {
|
||||
|
||||
void connect_handler(const asio::error_code&)
|
||||
struct connect_handler
|
||||
{
|
||||
}
|
||||
connect_handler() {}
|
||||
void operator()(const asio::error_code&) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
connect_handler(connect_handler&&) {}
|
||||
private:
|
||||
connect_handler(const connect_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void send_handler(const asio::error_code&, std::size_t)
|
||||
struct send_handler
|
||||
{
|
||||
}
|
||||
send_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
send_handler(send_handler&&) {}
|
||||
private:
|
||||
send_handler(const send_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void receive_handler(const asio::error_code&, std::size_t)
|
||||
struct receive_handler
|
||||
{
|
||||
}
|
||||
receive_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receive_handler(receive_handler&&) {}
|
||||
private:
|
||||
receive_handler(const receive_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void write_some_handler(const asio::error_code&, std::size_t)
|
||||
struct write_some_handler
|
||||
{
|
||||
}
|
||||
write_some_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
write_some_handler(write_some_handler&&) {}
|
||||
private:
|
||||
write_some_handler(const write_some_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void read_some_handler(const asio::error_code&, std::size_t)
|
||||
struct read_some_handler
|
||||
{
|
||||
}
|
||||
read_some_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
read_some_handler(read_some_handler&&) {}
|
||||
private:
|
||||
read_some_handler(const read_some_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -277,9 +312,9 @@ void test()
|
||||
socket1.connect(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
|
||||
|
||||
socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0),
|
||||
&connect_handler);
|
||||
connect_handler());
|
||||
socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0),
|
||||
&connect_handler);
|
||||
connect_handler());
|
||||
int i1 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0), lazy);
|
||||
(void)i1;
|
||||
int i2 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), lazy);
|
||||
@ -339,16 +374,16 @@ void test()
|
||||
socket1.send(const_buffers, in_flags, ec);
|
||||
socket1.send(null_buffers(), in_flags, ec);
|
||||
|
||||
socket1.async_send(buffer(mutable_char_buffer), &send_handler);
|
||||
socket1.async_send(buffer(const_char_buffer), &send_handler);
|
||||
socket1.async_send(mutable_buffers, &send_handler);
|
||||
socket1.async_send(const_buffers, &send_handler);
|
||||
socket1.async_send(null_buffers(), &send_handler);
|
||||
socket1.async_send(buffer(mutable_char_buffer), in_flags, &send_handler);
|
||||
socket1.async_send(buffer(const_char_buffer), in_flags, &send_handler);
|
||||
socket1.async_send(mutable_buffers, in_flags, &send_handler);
|
||||
socket1.async_send(const_buffers, in_flags, &send_handler);
|
||||
socket1.async_send(null_buffers(), in_flags, &send_handler);
|
||||
socket1.async_send(buffer(mutable_char_buffer), send_handler());
|
||||
socket1.async_send(buffer(const_char_buffer), send_handler());
|
||||
socket1.async_send(mutable_buffers, send_handler());
|
||||
socket1.async_send(const_buffers, send_handler());
|
||||
socket1.async_send(null_buffers(), send_handler());
|
||||
socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler());
|
||||
socket1.async_send(buffer(const_char_buffer), in_flags, send_handler());
|
||||
socket1.async_send(mutable_buffers, in_flags, send_handler());
|
||||
socket1.async_send(const_buffers, in_flags, send_handler());
|
||||
socket1.async_send(null_buffers(), in_flags, send_handler());
|
||||
int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
|
||||
(void)i3;
|
||||
int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
|
||||
@ -380,13 +415,13 @@ void test()
|
||||
socket1.receive(mutable_buffers, in_flags, ec);
|
||||
socket1.receive(null_buffers(), in_flags, ec);
|
||||
|
||||
socket1.async_receive(buffer(mutable_char_buffer), &receive_handler);
|
||||
socket1.async_receive(mutable_buffers, &receive_handler);
|
||||
socket1.async_receive(null_buffers(), &receive_handler);
|
||||
socket1.async_receive(buffer(mutable_char_buffer), receive_handler());
|
||||
socket1.async_receive(mutable_buffers, receive_handler());
|
||||
socket1.async_receive(null_buffers(), receive_handler());
|
||||
socket1.async_receive(buffer(mutable_char_buffer), in_flags,
|
||||
&receive_handler);
|
||||
socket1.async_receive(mutable_buffers, in_flags, &receive_handler);
|
||||
socket1.async_receive(null_buffers(), in_flags, &receive_handler);
|
||||
receive_handler());
|
||||
socket1.async_receive(mutable_buffers, in_flags, receive_handler());
|
||||
socket1.async_receive(null_buffers(), in_flags, receive_handler());
|
||||
int i13 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
|
||||
(void)i13;
|
||||
int i14 = socket1.async_receive(mutable_buffers, lazy);
|
||||
@ -412,11 +447,11 @@ void test()
|
||||
socket1.write_some(const_buffers, ec);
|
||||
socket1.write_some(null_buffers(), ec);
|
||||
|
||||
socket1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
|
||||
socket1.async_write_some(buffer(const_char_buffer), &write_some_handler);
|
||||
socket1.async_write_some(mutable_buffers, &write_some_handler);
|
||||
socket1.async_write_some(const_buffers, &write_some_handler);
|
||||
socket1.async_write_some(null_buffers(), &write_some_handler);
|
||||
socket1.async_write_some(buffer(mutable_char_buffer), write_some_handler());
|
||||
socket1.async_write_some(buffer(const_char_buffer), write_some_handler());
|
||||
socket1.async_write_some(mutable_buffers, write_some_handler());
|
||||
socket1.async_write_some(const_buffers, write_some_handler());
|
||||
socket1.async_write_some(null_buffers(), write_some_handler());
|
||||
int i19 = socket1.async_write_some(buffer(mutable_char_buffer), lazy);
|
||||
(void)i19;
|
||||
int i20 = socket1.async_write_some(buffer(const_char_buffer), lazy);
|
||||
@ -435,9 +470,9 @@ void test()
|
||||
socket1.read_some(mutable_buffers, ec);
|
||||
socket1.read_some(null_buffers(), ec);
|
||||
|
||||
socket1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
|
||||
socket1.async_read_some(mutable_buffers, &read_some_handler);
|
||||
socket1.async_read_some(null_buffers(), &read_some_handler);
|
||||
socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler());
|
||||
socket1.async_read_some(mutable_buffers, read_some_handler());
|
||||
socket1.async_read_some(null_buffers(), read_some_handler());
|
||||
int i24 = socket1.async_read_some(buffer(mutable_char_buffer), lazy);
|
||||
(void)i24;
|
||||
int i25 = socket1.async_read_some(mutable_buffers, lazy);
|
||||
@ -625,9 +660,16 @@ void test()
|
||||
|
||||
namespace ip_tcp_acceptor_compile {
|
||||
|
||||
void accept_handler(const asio::error_code&)
|
||||
struct accept_handler
|
||||
{
|
||||
}
|
||||
accept_handler() {}
|
||||
void operator()(const asio::error_code&) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
accept_handler(accept_handler&&) {}
|
||||
private:
|
||||
accept_handler(const accept_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -744,8 +786,8 @@ void test()
|
||||
acceptor1.accept(peer_socket, peer_endpoint);
|
||||
acceptor1.accept(peer_socket, peer_endpoint, ec);
|
||||
|
||||
acceptor1.async_accept(peer_socket, &accept_handler);
|
||||
acceptor1.async_accept(peer_socket, peer_endpoint, &accept_handler);
|
||||
acceptor1.async_accept(peer_socket, accept_handler());
|
||||
acceptor1.async_accept(peer_socket, peer_endpoint, accept_handler());
|
||||
int i1 = acceptor1.async_accept(peer_socket, lazy);
|
||||
(void)i1;
|
||||
int i2 = acceptor1.async_accept(peer_socket, peer_endpoint, lazy);
|
||||
@ -846,10 +888,17 @@ void test()
|
||||
|
||||
namespace ip_tcp_resolver_compile {
|
||||
|
||||
void resolve_handler(const asio::error_code&,
|
||||
asio::ip::tcp::resolver::iterator)
|
||||
struct resolve_handler
|
||||
{
|
||||
}
|
||||
resolve_handler() {}
|
||||
void operator()(const asio::error_code&,
|
||||
asio::ip::tcp::resolver::iterator) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
resolve_handler(resolve_handler&&) {}
|
||||
private:
|
||||
resolve_handler(const resolve_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -889,11 +938,11 @@ void test()
|
||||
ip::tcp::resolver::iterator iter4 = resolver.resolve(e, ec);
|
||||
(void)iter4;
|
||||
|
||||
resolver.async_resolve(q, &resolve_handler);
|
||||
resolver.async_resolve(q, resolve_handler());
|
||||
int i1 = resolver.async_resolve(q, lazy);
|
||||
(void)i1;
|
||||
|
||||
resolver.async_resolve(e, &resolve_handler);
|
||||
resolver.async_resolve(e, resolve_handler());
|
||||
int i2 = resolver.async_resolve(e, lazy);
|
||||
(void)i2;
|
||||
}
|
||||
|
@ -39,17 +39,38 @@
|
||||
|
||||
namespace ip_udp_socket_compile {
|
||||
|
||||
void connect_handler(const asio::error_code&)
|
||||
struct connect_handler
|
||||
{
|
||||
}
|
||||
connect_handler() {}
|
||||
void operator()(const asio::error_code&) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
connect_handler(connect_handler&&) {}
|
||||
private:
|
||||
connect_handler(const connect_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void send_handler(const asio::error_code&, std::size_t)
|
||||
struct send_handler
|
||||
{
|
||||
}
|
||||
send_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
send_handler(send_handler&&) {}
|
||||
private:
|
||||
send_handler(const send_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void receive_handler(const asio::error_code&, std::size_t)
|
||||
struct receive_handler
|
||||
{
|
||||
}
|
||||
receive_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
receive_handler(receive_handler&&) {}
|
||||
private:
|
||||
receive_handler(const receive_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -159,9 +180,9 @@ void test()
|
||||
socket1.connect(ip::udp::endpoint(ip::udp::v6(), 0), ec);
|
||||
|
||||
socket1.async_connect(ip::udp::endpoint(ip::udp::v4(), 0),
|
||||
&connect_handler);
|
||||
connect_handler());
|
||||
socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0),
|
||||
&connect_handler);
|
||||
connect_handler());
|
||||
int i1 = socket1.async_connect(ip::udp::endpoint(ip::udp::v4(), 0), lazy);
|
||||
(void)i1;
|
||||
int i2 = socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), lazy);
|
||||
@ -215,12 +236,12 @@ void test()
|
||||
socket1.send(buffer(const_char_buffer), in_flags, ec);
|
||||
socket1.send(null_buffers(), in_flags, ec);
|
||||
|
||||
socket1.async_send(buffer(mutable_char_buffer), &send_handler);
|
||||
socket1.async_send(buffer(const_char_buffer), &send_handler);
|
||||
socket1.async_send(null_buffers(), &send_handler);
|
||||
socket1.async_send(buffer(mutable_char_buffer), in_flags, &send_handler);
|
||||
socket1.async_send(buffer(const_char_buffer), in_flags, &send_handler);
|
||||
socket1.async_send(null_buffers(), in_flags, &send_handler);
|
||||
socket1.async_send(buffer(mutable_char_buffer), send_handler());
|
||||
socket1.async_send(buffer(const_char_buffer), send_handler());
|
||||
socket1.async_send(null_buffers(), send_handler());
|
||||
socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler());
|
||||
socket1.async_send(buffer(const_char_buffer), in_flags, send_handler());
|
||||
socket1.async_send(null_buffers(), in_flags, send_handler());
|
||||
int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
|
||||
(void)i3;
|
||||
int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
|
||||
@ -272,29 +293,29 @@ void test()
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);
|
||||
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), in_flags, &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), in_flags, &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(buffer(const_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), in_flags, &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler());
|
||||
socket1.async_send_to(null_buffers(),
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, &send_handler);
|
||||
ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler());
|
||||
int i9 = socket1.async_send_to(buffer(mutable_char_buffer),
|
||||
ip::udp::endpoint(ip::udp::v4(), 0), lazy);
|
||||
(void)i9;
|
||||
@ -339,11 +360,11 @@ void test()
|
||||
socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
|
||||
socket1.receive(null_buffers(), in_flags, ec);
|
||||
|
||||
socket1.async_receive(buffer(mutable_char_buffer), &receive_handler);
|
||||
socket1.async_receive(null_buffers(), &receive_handler);
|
||||
socket1.async_receive(buffer(mutable_char_buffer), receive_handler());
|
||||
socket1.async_receive(null_buffers(), receive_handler());
|
||||
socket1.async_receive(buffer(mutable_char_buffer), in_flags,
|
||||
&receive_handler);
|
||||
socket1.async_receive(null_buffers(), in_flags, &receive_handler);
|
||||
receive_handler());
|
||||
socket1.async_receive(null_buffers(), in_flags, receive_handler());
|
||||
int i21 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
|
||||
(void)i21;
|
||||
int i22 = socket1.async_receive(null_buffers(), lazy);
|
||||
@ -363,13 +384,13 @@ void test()
|
||||
socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
|
||||
|
||||
socket1.async_receive_from(buffer(mutable_char_buffer),
|
||||
endpoint, &receive_handler);
|
||||
endpoint, receive_handler());
|
||||
socket1.async_receive_from(null_buffers(),
|
||||
endpoint, &receive_handler);
|
||||
endpoint, receive_handler());
|
||||
socket1.async_receive_from(buffer(mutable_char_buffer),
|
||||
endpoint, in_flags, &receive_handler);
|
||||
endpoint, in_flags, receive_handler());
|
||||
socket1.async_receive_from(null_buffers(),
|
||||
endpoint, in_flags, &receive_handler);
|
||||
endpoint, in_flags, receive_handler());
|
||||
int i25 = socket1.async_receive_from(buffer(mutable_char_buffer),
|
||||
endpoint, lazy);
|
||||
(void)i25;
|
||||
@ -470,10 +491,17 @@ void test()
|
||||
|
||||
namespace ip_udp_resolver_compile {
|
||||
|
||||
void resolve_handler(const asio::error_code&,
|
||||
asio::ip::udp::resolver::iterator)
|
||||
struct resolve_handler
|
||||
{
|
||||
}
|
||||
resolve_handler() {}
|
||||
void operator()(const asio::error_code&,
|
||||
asio::ip::udp::resolver::iterator) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
resolve_handler(resolve_handler&&) {}
|
||||
private:
|
||||
resolve_handler(const resolve_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -513,11 +541,11 @@ void test()
|
||||
ip::udp::resolver::iterator iter4 = resolver.resolve(e, ec);
|
||||
(void)iter4;
|
||||
|
||||
resolver.async_resolve(q, &resolve_handler);
|
||||
resolver.async_resolve(q, resolve_handler());
|
||||
int i1 = resolver.async_resolve(q, lazy);
|
||||
(void)i1;
|
||||
|
||||
resolver.async_resolve(e, &resolve_handler);
|
||||
resolver.async_resolve(e, resolve_handler());
|
||||
int i2 = resolver.async_resolve(e, lazy);
|
||||
(void)i2;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
#include "archetypes/async_result.hpp"
|
||||
#include "asio/io_service.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/streambuf.hpp"
|
||||
#include "unit_test.hpp"
|
||||
|
||||
@ -42,7 +43,7 @@ using namespace std; // For memcmp, memcpy and memset.
|
||||
class test_stream
|
||||
{
|
||||
public:
|
||||
typedef asio::io_service io_service_type;
|
||||
typedef asio::io_service::executor_type executor_type;
|
||||
|
||||
test_stream(asio::io_service& io_service)
|
||||
: io_service_(io_service),
|
||||
@ -52,9 +53,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
io_service_type& get_io_service()
|
||||
executor_type get_executor() ASIO_NOEXCEPT
|
||||
{
|
||||
return io_service_;
|
||||
return io_service_.get_executor();
|
||||
}
|
||||
|
||||
void reset(const void* data, size_t length)
|
||||
@ -117,12 +118,14 @@ public:
|
||||
void async_read_some(const Mutable_Buffers& buffers, Handler handler)
|
||||
{
|
||||
size_t bytes_transferred = read_some(buffers);
|
||||
io_service_.post(asio::detail::bind_handler(
|
||||
handler, asio::error_code(), bytes_transferred));
|
||||
asio::post(get_executor(),
|
||||
asio::detail::bind_handler(
|
||||
ASIO_MOVE_CAST(Handler)(handler),
|
||||
asio::error_code(), bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
io_service_type& io_service_;
|
||||
asio::io_service& io_service_;
|
||||
enum { max_length = 8192 };
|
||||
char data_[max_length];
|
||||
size_t length_;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <cstring>
|
||||
#include "archetypes/async_result.hpp"
|
||||
#include "asio/io_service.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/streambuf.hpp"
|
||||
#include "unit_test.hpp"
|
||||
|
||||
@ -41,7 +42,7 @@ using namespace std; // For memcmp, memcpy and memset.
|
||||
class test_random_access_device
|
||||
{
|
||||
public:
|
||||
typedef asio::io_service io_service_type;
|
||||
typedef asio::io_service::executor_type executor_type;
|
||||
|
||||
test_random_access_device(asio::io_service& io_service)
|
||||
: io_service_(io_service),
|
||||
@ -50,9 +51,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
io_service_type& get_io_service()
|
||||
executor_type get_executor() ASIO_NOEXCEPT
|
||||
{
|
||||
return io_service_;
|
||||
return io_service_.get_executor();
|
||||
}
|
||||
|
||||
void reset(const void* data, size_t length)
|
||||
@ -120,12 +121,14 @@ public:
|
||||
const Mutable_Buffers& buffers, Handler handler)
|
||||
{
|
||||
size_t bytes_transferred = read_some_at(offset, buffers);
|
||||
io_service_.post(asio::detail::bind_handler(
|
||||
handler, asio::error_code(), bytes_transferred));
|
||||
asio::post(get_executor(),
|
||||
asio::detail::bind_handler(
|
||||
ASIO_MOVE_CAST(Handler)(handler),
|
||||
asio::error_code(), bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
io_service_type& io_service_;
|
||||
asio::io_service& io_service_;
|
||||
enum { max_length = 8192 };
|
||||
char data_[max_length];
|
||||
size_t length_;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <cstring>
|
||||
#include "archetypes/async_result.hpp"
|
||||
#include "asio/io_service.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/streambuf.hpp"
|
||||
#include "unit_test.hpp"
|
||||
|
||||
@ -31,7 +32,7 @@
|
||||
class test_stream
|
||||
{
|
||||
public:
|
||||
typedef asio::io_service io_service_type;
|
||||
typedef asio::io_service::executor_type executor_type;
|
||||
|
||||
test_stream(asio::io_service& io_service)
|
||||
: io_service_(io_service),
|
||||
@ -41,9 +42,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
io_service_type& get_io_service()
|
||||
executor_type get_executor() ASIO_NOEXCEPT
|
||||
{
|
||||
return io_service_;
|
||||
return io_service_.get_executor();
|
||||
}
|
||||
|
||||
void reset(const void* data, size_t length)
|
||||
@ -85,12 +86,14 @@ public:
|
||||
void async_read_some(const Mutable_Buffers& buffers, Handler handler)
|
||||
{
|
||||
size_t bytes_transferred = read_some(buffers);
|
||||
io_service_.post(asio::detail::bind_handler(
|
||||
handler, asio::error_code(), bytes_transferred));
|
||||
asio::post(get_executor(),
|
||||
asio::detail::bind_handler(
|
||||
ASIO_MOVE_CAST(Handler)(handler),
|
||||
asio::error_code(), bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
io_service_type& io_service_;
|
||||
asio::io_service& io_service_;
|
||||
enum { max_length = 8192 };
|
||||
char data_[max_length];
|
||||
size_t length_;
|
||||
|
@ -30,13 +30,27 @@
|
||||
|
||||
namespace serial_port_compile {
|
||||
|
||||
void write_some_handler(const asio::error_code&, std::size_t)
|
||||
struct write_some_handler
|
||||
{
|
||||
}
|
||||
write_some_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
write_some_handler(write_some_handler&&) {}
|
||||
private:
|
||||
write_some_handler(const write_some_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void read_some_handler(const asio::error_code&, std::size_t)
|
||||
struct read_some_handler
|
||||
{
|
||||
}
|
||||
read_some_handler() {}
|
||||
void operator()(const asio::error_code&, std::size_t) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
read_some_handler(read_some_handler&&) {}
|
||||
private:
|
||||
read_some_handler(const read_some_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void test()
|
||||
{
|
||||
@ -118,8 +132,8 @@ void test()
|
||||
port1.write_some(buffer(mutable_char_buffer), ec);
|
||||
port1.write_some(buffer(const_char_buffer), ec);
|
||||
|
||||
port1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
|
||||
port1.async_write_some(buffer(const_char_buffer), &write_some_handler);
|
||||
port1.async_write_some(buffer(mutable_char_buffer), write_some_handler());
|
||||
port1.async_write_some(buffer(const_char_buffer), write_some_handler());
|
||||
int i1 = port1.async_write_some(buffer(mutable_char_buffer), lazy);
|
||||
(void)i1;
|
||||
int i2 = port1.async_write_some(buffer(const_char_buffer), lazy);
|
||||
@ -128,7 +142,7 @@ void test()
|
||||
port1.read_some(buffer(mutable_char_buffer));
|
||||
port1.read_some(buffer(mutable_char_buffer), ec);
|
||||
|
||||
port1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
|
||||
port1.async_read_some(buffer(mutable_char_buffer), read_some_handler());
|
||||
int i3 = port1.async_read_some(buffer(mutable_char_buffer), lazy);
|
||||
(void)i3;
|
||||
}
|
||||
|
@ -233,9 +233,16 @@ void system_timer_test()
|
||||
ASIO_CHECK(expected_end < end || expected_end == end);
|
||||
}
|
||||
|
||||
void timer_handler(const asio::error_code&)
|
||||
struct timer_handler
|
||||
{
|
||||
}
|
||||
timer_handler() {}
|
||||
void operator()(const asio::error_code&) {}
|
||||
#if defined(ASIO_HAS_MOVE)
|
||||
timer_handler(timer_handler&&) {}
|
||||
private:
|
||||
timer_handler(const timer_handler&);
|
||||
#endif // defined(ASIO_HAS_MOVE)
|
||||
};
|
||||
|
||||
void system_timer_cancel_test()
|
||||
{
|
||||
@ -249,10 +256,10 @@ void system_timer_cancel_test()
|
||||
}
|
||||
} timers[50];
|
||||
|
||||
timers[2].t.async_wait(&timer_handler);
|
||||
timers[41].t.async_wait(&timer_handler);
|
||||
timers[2].t.async_wait(timer_handler());
|
||||
timers[41].t.async_wait(timer_handler());
|
||||
for (int i = 10; i < 20; ++i)
|
||||
timers[i].t.async_wait(&timer_handler);
|
||||
timers[i].t.async_wait(timer_handler());
|
||||
|
||||
ASIO_CHECK(timers[2].t.cancel() == 1);
|
||||
ASIO_CHECK(timers[41].t.cancel() == 1);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
#include "archetypes/async_result.hpp"
|
||||
#include "asio/io_service.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/streambuf.hpp"
|
||||
#include "unit_test.hpp"
|
||||
|
||||
@ -42,7 +43,7 @@ using namespace std; // For memcmp, memcpy and memset.
|
||||
class test_stream
|
||||
{
|
||||
public:
|
||||
typedef asio::io_service io_service_type;
|
||||
typedef asio::io_service::executor_type executor_type;
|
||||
|
||||
test_stream(asio::io_service& io_service)
|
||||
: io_service_(io_service),
|
||||
@ -53,9 +54,9 @@ public:
|
||||
memset(data_, 0, max_length);
|
||||
}
|
||||
|
||||
io_service_type& get_io_service()
|
||||
executor_type get_executor() ASIO_NOEXCEPT
|
||||
{
|
||||
return io_service_;
|
||||
return io_service_.get_executor();
|
||||
}
|
||||
|
||||
void reset(size_t length = max_length)
|
||||
@ -117,12 +118,14 @@ public:
|
||||
void async_write_some(const Const_Buffers& buffers, Handler handler)
|
||||
{
|
||||
size_t bytes_transferred = write_some(buffers);
|
||||
io_service_.post(asio::detail::bind_handler(
|
||||
handler, asio::error_code(), bytes_transferred));
|
||||
asio::post(get_executor(),
|
||||
asio::detail::bind_handler(
|
||||
ASIO_MOVE_CAST(Handler)(handler),
|
||||
asio::error_code(), bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
io_service_type& io_service_;
|
||||
asio::io_service& io_service_;
|
||||
enum { max_length = 8192 };
|
||||
char data_[max_length];
|
||||
size_t length_;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <cstring>
|
||||
#include "archetypes/async_result.hpp"
|
||||
#include "asio/io_service.hpp"
|
||||
#include "asio/post.hpp"
|
||||
#include "asio/streambuf.hpp"
|
||||
#include "unit_test.hpp"
|
||||
|
||||
@ -41,7 +42,7 @@ using namespace std; // For memcmp, memcpy and memset.
|
||||
class test_random_access_device
|
||||
{
|
||||
public:
|
||||
typedef asio::io_service io_service_type;
|
||||
typedef asio::io_service::executor_type executor_type;
|
||||
|
||||
test_random_access_device(asio::io_service& io_service)
|
||||
: io_service_(io_service),
|
||||
@ -51,9 +52,9 @@ public:
|
||||
memset(data_, 0, max_length);
|
||||
}
|
||||
|
||||
io_service_type& get_io_service()
|
||||
executor_type get_executor() ASIO_NOEXCEPT
|
||||
{
|
||||
return io_service_;
|
||||
return io_service_.get_executor();
|
||||
}
|
||||
|
||||
void reset()
|
||||
@ -113,12 +114,14 @@ public:
|
||||
const Const_Buffers& buffers, Handler handler)
|
||||
{
|
||||
size_t bytes_transferred = write_some_at(offset, buffers);
|
||||
io_service_.post(asio::detail::bind_handler(
|
||||
handler, asio::error_code(), bytes_transferred));
|
||||
asio::post(get_executor(),
|
||||
asio::detail::bind_handler(
|
||||
ASIO_MOVE_CAST(Handler)(handler),
|
||||
asio::error_code(), bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
io_service_type& io_service_;
|
||||
asio::io_service& io_service_;
|
||||
enum { max_length = 8192 };
|
||||
char data_[max_length];
|
||||
size_t length_;
|
||||
|
Loading…
Reference in New Issue
Block a user