reactive_socket_connect_op(socket_type socket, Handler& handler) : reactive_socket_connect_op_base(socket, &reactive_socket_connect_op::do_complete), handler_(NET_TS_MOVE_CAST(Handler)(handler)) { handler_work<Handler>::start(handler_); }
reactive_null_buffers_op(Handler& handler) : reactor_op(&reactive_null_buffers_op::do_perform, &reactive_null_buffers_op::do_complete), handler_(NET_TS_MOVE_CAST(Handler)(handler)) { handler_work<Handler>::start(handler_); }
reactive_socket_recvmsg_op(socket_type socket, const MutableBufferSequence& buffers, socket_base::message_flags in_flags, socket_base::message_flags& out_flags, Handler& handler) : reactive_socket_recvmsg_op_base<MutableBufferSequence>(socket, buffers, in_flags, out_flags, &reactive_socket_recvmsg_op::do_complete), handler_(NET_TS_MOVE_CAST(Handler)(handler)) { handler_work<Handler>::start(handler_); }
win_iocp_socket_recvmsg_op( socket_ops::weak_cancel_token_type cancel_token, const MutableBufferSequence& buffers, socket_base::message_flags& out_flags, Handler& handler) : operation(&win_iocp_socket_recvmsg_op::do_complete), cancel_token_(cancel_token), buffers_(buffers), out_flags_(out_flags), handler_(NET_TS_MOVE_CAST(Handler)(handler)) { handler_work<Handler>::start(handler_); }
void complete(Function& function, Handler& handler) { executor_.dispatch(NET_TS_MOVE_CAST(Function)(function), associated_allocator<Handler>::get(handler)); }
namespace detail { #if defined(NET_TS_ENABLE_HANDLER_TYPE_REQUIREMENTS) # if defined(NET_TS_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT) template <typename Handler> 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_copyable_handler_test(Handler, ...))[2]; template <typename Handler, typename Arg1> auto one_arg_handler_test(Handler h, Arg1* a1) -> decltype( sizeof(Handler(NET_TS_MOVE_CAST(Handler)(h))), ((h)(*a1)), char(0)); template <typename Handler> 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(NET_TS_MOVE_CAST(Handler)(h))), ((h)(*a1, *a2)), char(0)); template <typename Handler> char (&two_arg_handler_test(Handler, ...))[2]; template <typename Handler, typename Arg1, typename Arg2> auto two_arg_move_handler_test(Handler h, Arg1* a1, Arg2* a2) -> decltype( sizeof(Handler(NET_TS_MOVE_CAST(Handler)(h))), ((h)(*a1, NET_TS_MOVE_CAST(Arg2)(*a2))), char(0)); template <typename Handler> char (&two_arg_move_handler_test(Handler, ...))[2]; # define NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT(expr, msg) \ static_assert(expr, msg); # else // defined(NET_TS_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT) # define NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT(expr, msg) # endif // defined(NET_TS_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT) 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(NET_TS_HAS_MOVE) template <typename T> T rvref(); template <typename T> T rvref(T); #else // defined(NET_TS_HAS_MOVE) template <typename T> const T& rvref(); template <typename T> const T& rvref(T); #endif // defined(NET_TS_HAS_MOVE) template <typename T> char argbyv(T); template <int> struct handler_type_requirements { }; #define NET_TS_COMPLETION_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void()) networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::zero_arg_copyable_handler_test( \ std::experimental::net::detail::clvref< \ networking_ts_true_handler_type>(), 0)) == 1, \ "CompletionHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::clvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()(), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_READ_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, std::size_t)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const std::size_t*>(0))) == 1, \ "ReadHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const std::size_t>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_WRITE_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, std::size_t)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const std::size_t*>(0))) == 1, \ "WriteHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const std::size_t>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_ACCEPT_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::one_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0))) == 1, \ "AcceptHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_MOVE_ACCEPT_HANDLER_CHECK( \ handler_type, handler, socket_type) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, socket_type)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_move_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<socket_type*>(0))) == 1, \ "MoveAcceptHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::rvref<socket_type>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_CONNECT_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::one_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0))) == 1, \ "ConnectHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_RANGE_CONNECT_HANDLER_CHECK( \ handler_type, handler, endpoint_type) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, endpoint_type)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const endpoint_type*>(0))) == 1, \ "RangeConnectHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const endpoint_type>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_ITERATOR_CONNECT_HANDLER_CHECK( \ handler_type, handler, iter_type) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, iter_type)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const iter_type*>(0))) == 1, \ "IteratorConnectHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const iter_type>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_RESOLVE_HANDLER_CHECK( \ handler_type, handler, range_type) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, range_type)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const range_type*>(0))) == 1, \ "ResolveHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const range_type>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_WAIT_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::one_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0))) == 1, \ "WaitHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_SIGNAL_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, int)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const int*>(0))) == 1, \ "SignalHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const int>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_HANDSHAKE_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::one_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0))) == 1, \ "HandshakeHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_BUFFERED_HANDSHAKE_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code, std::size_t)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::two_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0), \ static_cast<const std::size_t*>(0))) == 1, \ "BufferedHandshakeHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>(), \ std::experimental::net::detail::lvref<const std::size_t>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #define NET_TS_SHUTDOWN_HANDLER_CHECK( \ handler_type, handler) \ \ typedef NET_TS_HANDLER_TYPE(handler_type, \ void(std::error_code)) \ networking_ts_true_handler_type; \ \ NET_TS_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(std::experimental::net::detail::one_arg_handler_test( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>(), \ static_cast<const std::error_code*>(0))) == 1, \ "ShutdownHandler type requirements not met") \ \ typedef std::experimental::net::detail::handler_type_requirements< \ sizeof( \ std::experimental::net::detail::argbyv( \ std::experimental::net::detail::rvref< \ networking_ts_true_handler_type>())) + \ sizeof( \ std::experimental::net::detail::lvref< \ networking_ts_true_handler_type>()( \ std::experimental::net::detail::lvref<const std::error_code>()), \ char(0))> NET_TS_UNUSED_TYPEDEF #else // !defined(NET_TS_ENABLE_HANDLER_TYPE_REQUIREMENTS) #define NET_TS_COMPLETION_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_READ_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_WRITE_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_ACCEPT_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_CONNECT_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_RANGE_CONNECT_HANDLER_CHECK( \ handler_type, handler, iter_type) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_ITERATOR_CONNECT_HANDLER_CHECK( \ handler_type, handler, iter_type) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_RESOLVE_HANDLER_CHECK( \ handler_type, handler, iter_type) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_WAIT_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_SIGNAL_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_HANDSHAKE_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_BUFFERED_HANDSHAKE_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #define NET_TS_SHUTDOWN_HANDLER_CHECK( \ handler_type, handler) \ typedef int NET_TS_UNUSED_TYPEDEF #endif // !defined(NET_TS_ENABLE_HANDLER_TYPE_REQUIREMENTS) } // namespace detail
winrt_socket_connect_op(Handler& handler) : winrt_async_op<void>(&winrt_socket_connect_op::do_complete), handler_(NET_TS_MOVE_CAST(Handler)(handler)) { handler_work<Handler>::start(handler_); }