Minimise copying of handler function objects. Use move construction when

available.
This commit is contained in:
Christopher Kohlhoff 2011-02-08 18:09:58 +11:00
parent f57386e3bb
commit f8d583bbb5
58 changed files with 294 additions and 184 deletions

View File

@ -248,7 +248,8 @@ public:
template <typename ConstBufferSequence, typename WriteHandler> template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers, WriteHandler handler) void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, 0, handler); this->service.async_send(this->implementation, buffers, 0,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Start an asynchronous send on a connected socket. /// Start an asynchronous send on a connected socket.
@ -284,7 +285,8 @@ public:
void async_send(const ConstBufferSequence& buffers, void async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags, WriteHandler handler) socket_base::message_flags flags, WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, flags, handler); this->service.async_send(this->implementation, buffers, flags,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Send a datagram to the specified endpoint. /// Send a datagram to the specified endpoint.
@ -417,7 +419,7 @@ public:
const endpoint_type& destination, WriteHandler handler) const endpoint_type& destination, WriteHandler handler)
{ {
this->service.async_send_to(this->implementation, buffers, destination, 0, this->service.async_send_to(this->implementation, buffers, destination, 0,
handler); ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Start an asynchronous send. /// Start an asynchronous send.
@ -453,7 +455,7 @@ public:
WriteHandler handler) WriteHandler handler)
{ {
this->service.async_send_to(this->implementation, buffers, destination, this->service.async_send_to(this->implementation, buffers, destination,
flags, handler); flags, ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Receive some data on a connected socket. /// Receive some data on a connected socket.
@ -583,7 +585,8 @@ public:
template <typename MutableBufferSequence, typename ReadHandler> template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, 0, handler); this->service.async_receive(this->implementation, buffers, 0,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Start an asynchronous receive on a connected socket. /// Start an asynchronous receive on a connected socket.
@ -618,7 +621,8 @@ public:
void async_receive(const MutableBufferSequence& buffers, void async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, ReadHandler handler) socket_base::message_flags flags, ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, flags, handler); this->service.async_receive(this->implementation, buffers, flags,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Receive a datagram with the endpoint of the sender. /// Receive a datagram with the endpoint of the sender.
@ -751,7 +755,7 @@ public:
endpoint_type& sender_endpoint, ReadHandler handler) endpoint_type& sender_endpoint, ReadHandler handler)
{ {
this->service.async_receive_from(this->implementation, buffers, this->service.async_receive_from(this->implementation, buffers,
sender_endpoint, 0, handler); sender_endpoint, 0, ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Start an asynchronous receive. /// Start an asynchronous receive.
@ -789,7 +793,7 @@ public:
ReadHandler handler) ReadHandler handler)
{ {
this->service.async_receive_from(this->implementation, buffers, this->service.async_receive_from(this->implementation, buffers,
sender_endpoint, flags, handler); sender_endpoint, flags, ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };

View File

@ -492,7 +492,8 @@ public:
template <typename WaitHandler> template <typename WaitHandler>
void async_wait(WaitHandler handler) void async_wait(WaitHandler handler)
{ {
this->service.async_wait(this->implementation, handler); this->service.async_wait(this->implementation,
ASIO_MOVE_CAST(WaitHandler)(handler));
} }
}; };

View File

@ -244,7 +244,8 @@ public:
template <typename ConstBufferSequence, typename WriteHandler> template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers, WriteHandler handler) void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, 0, handler); this->service.async_send(this->implementation, buffers, 0,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Start an asynchronous send on a connected socket. /// Start an asynchronous send on a connected socket.
@ -279,7 +280,8 @@ public:
void async_send(const ConstBufferSequence& buffers, void async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags, WriteHandler handler) socket_base::message_flags flags, WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, flags, handler); this->service.async_send(this->implementation, buffers, flags,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Send raw data to the specified endpoint. /// Send raw data to the specified endpoint.
@ -412,7 +414,7 @@ public:
const endpoint_type& destination, WriteHandler handler) const endpoint_type& destination, WriteHandler handler)
{ {
this->service.async_send_to(this->implementation, buffers, destination, 0, this->service.async_send_to(this->implementation, buffers, destination, 0,
handler); ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Start an asynchronous send. /// Start an asynchronous send.
@ -448,7 +450,7 @@ public:
WriteHandler handler) WriteHandler handler)
{ {
this->service.async_send_to(this->implementation, buffers, destination, this->service.async_send_to(this->implementation, buffers, destination,
flags, handler); flags, ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Receive some data on a connected socket. /// Receive some data on a connected socket.
@ -578,7 +580,8 @@ public:
template <typename MutableBufferSequence, typename ReadHandler> template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, 0, handler); this->service.async_receive(this->implementation, buffers, 0,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Start an asynchronous receive on a connected socket. /// Start an asynchronous receive on a connected socket.
@ -613,7 +616,8 @@ public:
void async_receive(const MutableBufferSequence& buffers, void async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, ReadHandler handler) socket_base::message_flags flags, ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, flags, handler); this->service.async_receive(this->implementation, buffers, flags,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Receive raw data with the endpoint of the sender. /// Receive raw data with the endpoint of the sender.
@ -746,7 +750,7 @@ public:
endpoint_type& sender_endpoint, ReadHandler handler) endpoint_type& sender_endpoint, ReadHandler handler)
{ {
this->service.async_receive_from(this->implementation, buffers, this->service.async_receive_from(this->implementation, buffers,
sender_endpoint, 0, handler); sender_endpoint, 0, ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Start an asynchronous receive. /// Start an asynchronous receive.
@ -784,7 +788,7 @@ public:
ReadHandler handler) ReadHandler handler)
{ {
this->service.async_receive_from(this->implementation, buffers, this->service.async_receive_from(this->implementation, buffers,
sender_endpoint, flags, handler); sender_endpoint, flags, ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };

View File

@ -502,7 +502,8 @@ public:
void async_write_some(const ConstBufferSequence& buffers, void async_write_some(const ConstBufferSequence& buffers,
WriteHandler handler) WriteHandler handler)
{ {
this->service.async_write_some(this->implementation, buffers, handler); this->service.async_write_some(this->implementation, buffers,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Read some data from the serial port. /// Read some data from the serial port.
@ -606,7 +607,8 @@ public:
void async_read_some(const MutableBufferSequence& buffers, void async_read_some(const MutableBufferSequence& buffers,
ReadHandler handler) ReadHandler handler)
{ {
this->service.async_read_some(this->implementation, buffers, handler); this->service.async_read_some(this->implementation, buffers,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };

View File

@ -651,7 +651,8 @@ public:
} }
} }
this->service.async_connect(this->implementation, peer_endpoint, handler); this->service.async_connect(this->implementation, peer_endpoint,
ASIO_MOVE_CAST(ConnectHandler)(handler));
} }
/// Set an option on the socket. /// Set an option on the socket.

View File

@ -712,7 +712,8 @@ public:
void async_accept(basic_socket<protocol_type, SocketService>& peer, void async_accept(basic_socket<protocol_type, SocketService>& peer,
AcceptHandler handler) AcceptHandler handler)
{ {
this->service.async_accept(this->implementation, peer, 0, handler); this->service.async_accept(this->implementation, peer, 0,
ASIO_MOVE_CAST(AcceptHandler)(handler));
} }
/// Accept a new connection and obtain the endpoint of the peer /// Accept a new connection and obtain the endpoint of the peer
@ -813,8 +814,8 @@ public:
void async_accept(basic_socket<protocol_type, SocketService>& peer, void async_accept(basic_socket<protocol_type, SocketService>& peer,
endpoint_type& peer_endpoint, AcceptHandler handler) endpoint_type& peer_endpoint, AcceptHandler handler)
{ {
this->service.async_accept(this->implementation, this->service.async_accept(this->implementation, peer,
peer, &peer_endpoint, handler); &peer_endpoint, ASIO_MOVE_CAST(AcceptHandler)(handler));
} }
}; };

View File

@ -263,7 +263,8 @@ public:
template <typename ConstBufferSequence, typename WriteHandler> template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers, WriteHandler handler) void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, 0, handler); this->service.async_send(this->implementation, buffers, 0,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Start an asynchronous send. /// Start an asynchronous send.
@ -307,7 +308,8 @@ public:
void async_send(const ConstBufferSequence& buffers, void async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags, WriteHandler handler) socket_base::message_flags flags, WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, flags, handler); this->service.async_send(this->implementation, buffers, flags,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Receive some data on the socket. /// Receive some data on the socket.
@ -453,7 +455,8 @@ public:
template <typename MutableBufferSequence, typename ReadHandler> template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, 0, handler); this->service.async_receive(this->implementation, buffers, 0,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Start an asynchronous receive. /// Start an asynchronous receive.
@ -499,7 +502,8 @@ public:
void async_receive(const MutableBufferSequence& buffers, void async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags, ReadHandler handler) socket_base::message_flags flags, ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, flags, handler); this->service.async_receive(this->implementation, buffers, flags,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
/// Write some data to the socket. /// Write some data to the socket.
@ -600,7 +604,8 @@ public:
void async_write_some(const ConstBufferSequence& buffers, void async_write_some(const ConstBufferSequence& buffers,
WriteHandler handler) WriteHandler handler)
{ {
this->service.async_send(this->implementation, buffers, 0, handler); this->service.async_send(this->implementation, buffers, 0,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Read some data from the socket. /// Read some data from the socket.
@ -704,7 +709,8 @@ public:
void async_read_some(const MutableBufferSequence& buffers, void async_read_some(const MutableBufferSequence& buffers,
ReadHandler handler) ReadHandler handler)
{ {
this->service.async_receive(this->implementation, buffers, 0, handler); this->service.async_receive(this->implementation, buffers, 0,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };

View File

@ -34,6 +34,12 @@ public:
{ {
} }
binder1(Handler& handler, const Arg1& arg1)
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
arg1_(arg1)
{
}
void operator()() void operator()()
{ {
handler_(static_cast<const Arg1&>(arg1_)); handler_(static_cast<const Arg1&>(arg1_));
@ -91,6 +97,13 @@ public:
{ {
} }
binder2(Handler& handler, const Arg1& arg1, const Arg2& arg2)
: handler_(ASIO_MOVE_CAST(Handler)(handler)),
arg1_(arg1),
arg2_(arg2)
{
}
void operator()() void operator()()
{ {
handler_(static_cast<const Arg1&>(arg1_), handler_(static_cast<const Arg1&>(arg1_),
@ -152,6 +165,15 @@ public:
{ {
} }
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()() void operator()()
{ {
handler_(static_cast<const Arg1&>(arg1_), handler_(static_cast<const Arg1&>(arg1_),
@ -218,6 +240,16 @@ public:
{ {
} }
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()() void operator()()
{ {
handler_(static_cast<const Arg1&>(arg1_), handler_(static_cast<const Arg1&>(arg1_),
@ -292,6 +324,17 @@ public:
{ {
} }
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()() void operator()()
{ {
handler_(static_cast<const Arg1&>(arg1_), handler_(static_cast<const Arg1&>(arg1_),

View File

@ -32,9 +32,9 @@ class completion_handler : public operation
public: public:
ASIO_DEFINE_HANDLER_PTR(completion_handler); ASIO_DEFINE_HANDLER_PTR(completion_handler);
completion_handler(Handler h) completion_handler(Handler& h)
: operation(&completion_handler::do_complete), : operation(&completion_handler::do_complete),
handler_(h) handler_(ASIO_MOVE_CAST(Handler)(h))
{ {
} }
@ -51,7 +51,7 @@ public:
// with the handler. Consequently, a local copy of the handler is required // with the handler. Consequently, a local copy of the handler is required
// to ensure that any owning sub-object remains valid until after we have // to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here. // deallocated the memory here.
Handler handler(h->handler_); Handler handler(ASIO_MOVE_CAST(Handler)(h->handler_));
p.h = boost::addressof(handler); p.h = boost::addressof(handler);
p.reset(); p.reset();

View File

@ -46,6 +46,25 @@
# define ASIO_DECL # define ASIO_DECL
#endif // !defined(ASIO_DECL) #endif // !defined(ASIO_DECL)
// Support move construction on compilers known to allow it.
#if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define ASIO_MOVE_CAST(type) static_cast<type&&>
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
#endif // defined(__GNUC__)
#if defined(BOOST_MSVC)
# if (_MSC_VER >= 1600)
# define ASIO_MOVE_CAST(type) static_cast<type&&>
# endif // (_MSC_VER >= 1600)
#endif // defined(BOOST_MSVC)
// If ASIO_MOVE_CAST isn't defined yet use a C++03 compatible version.
#if !defined(ASIO_MOVE_CAST)
# define ASIO_MOVE_CAST(type) static_cast<const type&>
#endif // !defined_ASIO_MOVE_CAST
// Standard library support for system errors. // Standard library support for system errors.
#if !defined(ASIO_DISABLE_STD_SYSTEM_ERROR) #if !defined(ASIO_DISABLE_STD_SYSTEM_ERROR)
# if defined(__GNUC__) # if defined(__GNUC__)

View File

@ -174,7 +174,7 @@ public:
// Start an asynchronous wait on the timer. // Start an asynchronous wait on the timer.
template <typename Handler> template <typename Handler>
void async_wait(implementation_type& impl, Handler handler) void async_wait(implementation_type& impl, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef wait_handler<Handler> op; typedef wait_handler<Handler> op;

View File

@ -67,10 +67,10 @@ public:
ASIO_DEFINE_HANDLER_PTR(descriptor_read_op); ASIO_DEFINE_HANDLER_PTR(descriptor_read_op);
descriptor_read_op(int descriptor, descriptor_read_op(int descriptor,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
: descriptor_read_op_base<MutableBufferSequence>( : descriptor_read_op_base<MutableBufferSequence>(
descriptor, buffers, &descriptor_read_op::do_complete), descriptor, buffers, &descriptor_read_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -67,10 +67,10 @@ public:
ASIO_DEFINE_HANDLER_PTR(descriptor_write_op); ASIO_DEFINE_HANDLER_PTR(descriptor_write_op);
descriptor_write_op(int descriptor, descriptor_write_op(int descriptor,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
: descriptor_write_op_base<ConstBufferSequence>( : descriptor_write_op_base<ConstBufferSequence>(
descriptor, buffers, &descriptor_write_op::do_complete), descriptor, buffers, &descriptor_write_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -55,7 +55,7 @@ inline void strand_service::destroy(strand_service::implementation_type& impl)
template <typename Handler> template <typename Handler>
void strand_service::dispatch(strand_service::implementation_type& impl, void strand_service::dispatch(strand_service::implementation_type& impl,
Handler handler) Handler& handler)
{ {
// If we are already in the strand then the handler can run immediately. // If we are already in the strand then the handler can run immediately.
if (call_stack<strand_impl>::contains(impl)) if (call_stack<strand_impl>::contains(impl))
@ -111,7 +111,7 @@ void strand_service::dispatch(strand_service::implementation_type& impl,
// Request the io_service to invoke the given handler and return immediately. // Request the io_service to invoke the given handler and return immediately.
template <typename Handler> template <typename Handler>
void strand_service::post(strand_service::implementation_type& impl, void strand_service::post(strand_service::implementation_type& impl,
Handler handler) Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef completion_handler<Handler> op; typedef completion_handler<Handler> op;

View File

@ -27,7 +27,7 @@ namespace asio {
namespace detail { namespace detail {
template <typename Handler> template <typename Handler>
void task_io_service::dispatch(Handler handler) void task_io_service::dispatch(Handler& handler)
{ {
if (call_stack<task_io_service>::contains(this)) if (call_stack<task_io_service>::contains(this))
{ {
@ -39,7 +39,7 @@ void task_io_service::dispatch(Handler handler)
} }
template <typename Handler> template <typename Handler>
void task_io_service::post(Handler handler) void task_io_service::post(Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef completion_handler<Handler> op; typedef completion_handler<Handler> op;

View File

@ -31,7 +31,7 @@ namespace asio {
namespace detail { namespace detail {
template <typename Handler> template <typename Handler>
void win_iocp_io_service::dispatch(Handler handler) void win_iocp_io_service::dispatch(Handler& handler)
{ {
if (call_stack<win_iocp_io_service>::contains(this)) if (call_stack<win_iocp_io_service>::contains(this))
{ {
@ -43,7 +43,7 @@ void win_iocp_io_service::dispatch(Handler handler)
} }
template <typename Handler> template <typename Handler>
void win_iocp_io_service::post(Handler handler) void win_iocp_io_service::post(Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef completion_handler<Handler> op; typedef completion_handler<Handler> op;

View File

@ -142,7 +142,7 @@ public:
// lifetime of the asynchronous operation. // lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_write_some(implementation_type& impl, void async_write_some(implementation_type& impl,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef descriptor_write_op<ConstBufferSequence, Handler> op; typedef descriptor_write_op<ConstBufferSequence, Handler> op;
@ -160,7 +160,7 @@ public:
// Start an asynchronous wait until data can be written without blocking. // Start an asynchronous wait until data can be written without blocking.
template <typename Handler> template <typename Handler>
void async_write_some(implementation_type& impl, void async_write_some(implementation_type& impl,
const null_buffers&, Handler handler) const null_buffers&, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler> op; typedef reactive_null_buffers_op<Handler> op;
@ -199,7 +199,7 @@ public:
// valid for the lifetime of the asynchronous operation. // valid for the lifetime of the asynchronous operation.
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_read_some(implementation_type& impl, void async_read_some(implementation_type& impl,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef descriptor_read_op<MutableBufferSequence, Handler> op; typedef descriptor_read_op<MutableBufferSequence, Handler> op;
@ -217,7 +217,7 @@ public:
// Wait until data can be read without blocking. // Wait until data can be read without blocking.
template <typename Handler> template <typename Handler>
void async_read_some(implementation_type& impl, void async_read_some(implementation_type& impl,
const null_buffers&, Handler handler) const null_buffers&, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler> op; typedef reactive_null_buffers_op<Handler> op;

View File

@ -33,10 +33,10 @@ class reactive_null_buffers_op : public reactor_op
public: public:
ASIO_DEFINE_HANDLER_PTR(reactive_null_buffers_op); ASIO_DEFINE_HANDLER_PTR(reactive_null_buffers_op);
reactive_null_buffers_op(Handler handler) reactive_null_buffers_op(Handler& handler)
: reactor_op(&reactive_null_buffers_op::do_perform, : reactor_op(&reactive_null_buffers_op::do_perform,
&reactive_null_buffers_op::do_complete), &reactive_null_buffers_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -140,7 +140,7 @@ public:
// lifetime of the asynchronous operation. // lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_write_some(implementation_type& impl, void async_write_some(implementation_type& impl,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
{ {
descriptor_service_.async_write_some(impl, buffers, handler); descriptor_service_.async_write_some(impl, buffers, handler);
} }
@ -157,7 +157,7 @@ public:
// valid for the lifetime of the asynchronous operation. // valid for the lifetime of the asynchronous operation.
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_read_some(implementation_type& impl, void async_read_some(implementation_type& impl,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
{ {
descriptor_service_.async_read_some(impl, buffers, handler); descriptor_service_.async_read_some(impl, buffers, handler);
} }

View File

@ -86,10 +86,10 @@ public:
reactive_socket_accept_op(socket_type socket, reactive_socket_accept_op(socket_type socket,
socket_ops::state_type state, Socket& peer, const Protocol& protocol, socket_ops::state_type state, Socket& peer, const Protocol& protocol,
typename Protocol::endpoint* peer_endpoint, Handler handler) typename Protocol::endpoint* peer_endpoint, Handler& handler)
: reactive_socket_accept_op_base<Socket, Protocol>(socket, state, peer, : reactive_socket_accept_op_base<Socket, Protocol>(socket, state, peer,
protocol, peer_endpoint, &reactive_socket_accept_op::do_complete), protocol, peer_endpoint, &reactive_socket_accept_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -55,10 +55,10 @@ class reactive_socket_connect_op : public reactive_socket_connect_op_base
public: public:
ASIO_DEFINE_HANDLER_PTR(reactive_socket_connect_op); ASIO_DEFINE_HANDLER_PTR(reactive_socket_connect_op);
reactive_socket_connect_op(socket_type socket, Handler handler) reactive_socket_connect_op(socket_type socket, Handler& handler)
: reactive_socket_connect_op_base(socket, : reactive_socket_connect_op_base(socket,
&reactive_socket_connect_op::do_complete), &reactive_socket_connect_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -73,10 +73,10 @@ public:
reactive_socket_recv_op(socket_type socket, reactive_socket_recv_op(socket_type socket,
socket_ops::state_type state, const MutableBufferSequence& buffers, socket_ops::state_type state, const MutableBufferSequence& buffers,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
: reactive_socket_recv_op_base<MutableBufferSequence>(socket, state, : reactive_socket_recv_op_base<MutableBufferSequence>(socket, state,
buffers, flags, &reactive_socket_recv_op::do_complete), buffers, flags, &reactive_socket_recv_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -81,11 +81,11 @@ public:
reactive_socket_recvfrom_op(socket_type socket, int protocol_type, reactive_socket_recvfrom_op(socket_type socket, int protocol_type,
const MutableBufferSequence& buffers, Endpoint& endpoint, const MutableBufferSequence& buffers, Endpoint& endpoint,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
: reactive_socket_recvfrom_op_base<MutableBufferSequence, Endpoint>( : reactive_socket_recvfrom_op_base<MutableBufferSequence, Endpoint>(
socket, protocol_type, buffers, endpoint, flags, socket, protocol_type, buffers, endpoint, flags,
&reactive_socket_recvfrom_op::do_complete), &reactive_socket_recvfrom_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -70,10 +70,10 @@ public:
reactive_socket_send_op(socket_type socket, reactive_socket_send_op(socket_type socket,
const ConstBufferSequence& buffers, const ConstBufferSequence& buffers,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
: reactive_socket_send_op_base<ConstBufferSequence>(socket, : reactive_socket_send_op_base<ConstBufferSequence>(socket,
buffers, flags, &reactive_socket_send_op::do_complete), buffers, flags, &reactive_socket_send_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -73,10 +73,10 @@ public:
reactive_socket_sendto_op(socket_type socket, reactive_socket_sendto_op(socket_type socket,
const ConstBufferSequence& buffers, const Endpoint& endpoint, const ConstBufferSequence& buffers, const Endpoint& endpoint,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
: reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint>(socket, : reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint>(socket,
buffers, endpoint, flags, &reactive_socket_sendto_op::do_complete), buffers, endpoint, flags, &reactive_socket_sendto_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -193,7 +193,7 @@ public:
void async_send_to(implementation_type& impl, void async_send_to(implementation_type& impl,
const ConstBufferSequence& buffers, const ConstBufferSequence& buffers,
const endpoint_type& destination, socket_base::message_flags flags, const endpoint_type& destination, socket_base::message_flags flags,
Handler handler) Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_sendto_op<ConstBufferSequence, typedef reactive_socket_sendto_op<ConstBufferSequence,
@ -210,7 +210,7 @@ public:
// Start an asynchronous wait until data can be sent without blocking. // Start an asynchronous wait until data can be sent without blocking.
template <typename Handler> template <typename Handler>
void async_send_to(implementation_type& impl, const null_buffers&, void async_send_to(implementation_type& impl, const null_buffers&,
const endpoint_type&, socket_base::message_flags, Handler handler) const endpoint_type&, socket_base::message_flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler> op; typedef reactive_null_buffers_op<Handler> op;
@ -265,7 +265,7 @@ public:
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_receive_from(implementation_type& impl, void async_receive_from(implementation_type& impl,
const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_recvfrom_op<MutableBufferSequence, typedef reactive_socket_recvfrom_op<MutableBufferSequence,
@ -288,7 +288,7 @@ public:
template <typename Handler> template <typename Handler>
void async_receive_from(implementation_type& impl, void async_receive_from(implementation_type& impl,
const null_buffers&, endpoint_type& sender_endpoint, const null_buffers&, endpoint_type& sender_endpoint,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler> op; typedef reactive_null_buffers_op<Handler> op;
@ -340,7 +340,7 @@ public:
// must be valid until the accept's handler is invoked. // must be valid until the accept's handler is invoked.
template <typename Socket, typename Handler> template <typename Socket, typename Handler>
void async_accept(implementation_type& impl, Socket& peer, void async_accept(implementation_type& impl, Socket& peer,
endpoint_type* peer_endpoint, Handler handler) endpoint_type* peer_endpoint, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_accept_op<Socket, Protocol, Handler> op; typedef reactive_socket_accept_op<Socket, Protocol, Handler> op;
@ -366,7 +366,7 @@ public:
// Start an asynchronous connect. // Start an asynchronous connect.
template <typename Handler> template <typename Handler>
void async_connect(implementation_type& impl, void async_connect(implementation_type& impl,
const endpoint_type& peer_endpoint, Handler handler) const endpoint_type& peer_endpoint, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_connect_op<Handler> op; typedef reactive_socket_connect_op<Handler> op;

View File

@ -159,7 +159,7 @@ public:
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_send(base_implementation_type& impl, void async_send(base_implementation_type& impl,
const ConstBufferSequence& buffers, const ConstBufferSequence& buffers,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_send_op<ConstBufferSequence, Handler> op; typedef reactive_socket_send_op<ConstBufferSequence, Handler> op;
@ -178,7 +178,7 @@ public:
// Start an asynchronous wait until data can be sent without blocking. // Start an asynchronous wait until data can be sent without blocking.
template <typename Handler> template <typename Handler>
void async_send(base_implementation_type& impl, const null_buffers&, void async_send(base_implementation_type& impl, const null_buffers&,
socket_base::message_flags, Handler handler) socket_base::message_flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler> op; typedef reactive_null_buffers_op<Handler> op;
@ -219,7 +219,7 @@ public:
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_receive(base_implementation_type& impl, void async_receive(base_implementation_type& impl,
const MutableBufferSequence& buffers, const MutableBufferSequence& buffers,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_recv_op<MutableBufferSequence, Handler> op; typedef reactive_socket_recv_op<MutableBufferSequence, Handler> op;
@ -241,7 +241,7 @@ public:
// Wait until data can be received without blocking. // Wait until data can be received without blocking.
template <typename Handler> template <typename Handler>
void async_receive(base_implementation_type& impl, const null_buffers&, void async_receive(base_implementation_type& impl, const null_buffers&,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler> op; typedef reactive_null_buffers_op<Handler> op;

View File

@ -42,12 +42,12 @@ public:
typedef asio::ip::basic_resolver_iterator<Protocol> iterator_type; typedef asio::ip::basic_resolver_iterator<Protocol> iterator_type;
resolve_endpoint_op(socket_ops::weak_cancel_token_type cancel_token, resolve_endpoint_op(socket_ops::weak_cancel_token_type cancel_token,
const endpoint_type& endpoint, io_service_impl& ios, Handler handler) const endpoint_type& endpoint, io_service_impl& ios, Handler& handler)
: operation(&resolve_endpoint_op::do_complete), : operation(&resolve_endpoint_op::do_complete),
cancel_token_(cancel_token), cancel_token_(cancel_token),
endpoint_(endpoint), endpoint_(endpoint),
io_service_impl_(ios), io_service_impl_(ios),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -43,12 +43,12 @@ public:
typedef asio::ip::basic_resolver_iterator<Protocol> iterator_type; typedef asio::ip::basic_resolver_iterator<Protocol> iterator_type;
resolve_op(socket_ops::weak_cancel_token_type cancel_token, resolve_op(socket_ops::weak_cancel_token_type cancel_token,
const query_type& query, io_service_impl& ios, Handler handler) const query_type& query, io_service_impl& ios, Handler& handler)
: operation(&resolve_op::do_complete), : operation(&resolve_op::do_complete),
cancel_token_(cancel_token), cancel_token_(cancel_token),
query_(query), query_(query),
io_service_impl_(ios), io_service_impl_(ios),
handler_(handler), handler_(ASIO_MOVE_CAST(Handler)(handler)),
addrinfo_(0) addrinfo_(0)
{ {
} }

View File

@ -66,8 +66,8 @@ public:
// Asynchronously resolve a query to a list of entries. // Asynchronously resolve a query to a list of entries.
template <typename Handler> template <typename Handler>
void async_resolve(implementation_type& impl, const query_type& query, void async_resolve(implementation_type& impl,
Handler handler) const query_type& query, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef resolve_op<Protocol, Handler> op; typedef resolve_op<Protocol, Handler> op;
@ -96,8 +96,8 @@ public:
// Asynchronously resolve an endpoint to a list of entries. // Asynchronously resolve an endpoint to a list of entries.
template <typename Handler> template <typename Handler>
void async_resolve(implementation_type& impl, const endpoint_type& endpoint, void async_resolve(implementation_type& impl,
Handler handler) const endpoint_type& endpoint, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef resolve_endpoint_op<Protocol, Handler> op; typedef resolve_endpoint_op<Protocol, Handler> op;

View File

@ -79,11 +79,11 @@ public:
// Request the io_service to invoke the given handler. // Request the io_service to invoke the given handler.
template <typename Handler> template <typename Handler>
void dispatch(implementation_type& impl, Handler handler); void dispatch(implementation_type& impl, Handler& handler);
// Request the io_service to invoke the given handler and return immediately. // Request the io_service to invoke the given handler and return immediately.
template <typename Handler> template <typename Handler>
void post(implementation_type& impl, Handler handler); void post(implementation_type& impl, Handler& handler);
private: private:
ASIO_DECL static void do_complete(io_service_impl* owner, ASIO_DECL static void do_complete(io_service_impl* owner,

View File

@ -84,11 +84,11 @@ public:
// Request invocation of the given handler. // Request invocation of the given handler.
template <typename Handler> template <typename Handler>
void dispatch(Handler handler); void dispatch(Handler& handler);
// Request invocation of the given handler and return immediately. // Request invocation of the given handler and return immediately.
template <typename Handler> template <typename Handler>
void post(Handler handler); void post(Handler& handler);
// Request invocation of the given operation and return immediately. Assumes // Request invocation of the given operation and return immediately. Assumes
// that work_started() has not yet been called for the operation. // that work_started() has not yet been called for the operation.

View File

@ -40,10 +40,11 @@ class win_iocp_handle_read_op : public operation
public: public:
ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_read_op); ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_read_op);
win_iocp_handle_read_op(const MutableBufferSequence& buffers, Handler handler) win_iocp_handle_read_op(
const MutableBufferSequence& buffers, Handler& handler)
: operation(&win_iocp_handle_read_op::do_complete), : operation(&win_iocp_handle_read_op::do_complete),
buffers_(buffers), buffers_(buffers),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -133,7 +133,7 @@ public:
// lifetime of the asynchronous operation. // lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_write_some(implementation_type& impl, void async_write_some(implementation_type& impl,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
{ {
async_write_some_at(impl, 0, buffers, handler); async_write_some_at(impl, 0, buffers, handler);
} }
@ -142,7 +142,7 @@ public:
// must be valid for the lifetime of the asynchronous operation. // must be valid for the lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_write_some_at(implementation_type& impl, boost::uint64_t offset, void async_write_some_at(implementation_type& impl, boost::uint64_t offset,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op; typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op;
@ -181,7 +181,7 @@ public:
// valid for the lifetime of the asynchronous operation. // valid for the lifetime of the asynchronous operation.
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_read_some(implementation_type& impl, void async_read_some(implementation_type& impl,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
{ {
async_read_some_at(impl, 0, buffers, handler); async_read_some_at(impl, 0, buffers, handler);
} }
@ -191,7 +191,7 @@ public:
// operation. // operation.
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_read_some_at(implementation_type& impl, boost::uint64_t offset, void async_read_some_at(implementation_type& impl, boost::uint64_t offset,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op; typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op;

View File

@ -40,10 +40,10 @@ class win_iocp_handle_write_op : public operation
public: public:
ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_write_op); ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_write_op);
win_iocp_handle_write_op(const ConstBufferSequence& buffers, Handler handler) win_iocp_handle_write_op(const ConstBufferSequence& buffers, Handler& handler)
: operation(&win_iocp_handle_write_op::do_complete), : operation(&win_iocp_handle_write_op::do_complete),
buffers_(buffers), buffers_(buffers),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -96,11 +96,11 @@ public:
// Request invocation of the given handler. // Request invocation of the given handler.
template <typename Handler> template <typename Handler>
void dispatch(Handler handler); void dispatch(Handler& handler);
// Request invocation of the given handler and return immediately. // Request invocation of the given handler and return immediately.
template <typename Handler> template <typename Handler>
void post(Handler handler); void post(Handler& handler);
// Request invocation of the given operation and return immediately. Assumes // Request invocation of the given operation and return immediately. Assumes
// that work_started() has not yet been called for the operation. // that work_started() has not yet been called for the operation.

View File

@ -41,11 +41,11 @@ public:
ASIO_DEFINE_HANDLER_PTR(win_iocp_null_buffers_op); ASIO_DEFINE_HANDLER_PTR(win_iocp_null_buffers_op);
win_iocp_null_buffers_op(socket_ops::weak_cancel_token_type cancel_token, win_iocp_null_buffers_op(socket_ops::weak_cancel_token_type cancel_token,
Handler handler) Handler& handler)
: reactor_op(&win_iocp_null_buffers_op::do_perform, : reactor_op(&win_iocp_null_buffers_op::do_perform,
&win_iocp_null_buffers_op::do_complete), &win_iocp_null_buffers_op::do_complete),
cancel_token_(cancel_token), cancel_token_(cancel_token),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -38,9 +38,9 @@ class win_iocp_overlapped_op : public operation
public: public:
ASIO_DEFINE_HANDLER_PTR(win_iocp_overlapped_op); ASIO_DEFINE_HANDLER_PTR(win_iocp_overlapped_op);
win_iocp_overlapped_op(Handler handler) win_iocp_overlapped_op(Handler& handler)
: operation(&win_iocp_overlapped_op::do_complete), : operation(&win_iocp_overlapped_op::do_complete),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -46,7 +46,7 @@ public:
// Construct an win_iocp_overlapped_ptr to contain the specified handler. // Construct an win_iocp_overlapped_ptr to contain the specified handler.
template <typename Handler> template <typename Handler>
explicit win_iocp_overlapped_ptr( explicit win_iocp_overlapped_ptr(
asio::io_service& io_service, Handler handler) asio::io_service& io_service, Handler& handler)
: ptr_(0), : ptr_(0),
iocp_service_(0) iocp_service_(0)
{ {
@ -74,7 +74,7 @@ public:
// Reset to contain the specified handler, freeing any current OVERLAPPED // Reset to contain the specified handler, freeing any current OVERLAPPED
// object. // object.
template <typename Handler> template <typename Handler>
void reset(asio::io_service& io_service, Handler handler) void reset(asio::io_service& io_service, Handler& handler)
{ {
typedef win_iocp_overlapped_op<Handler> op; typedef win_iocp_overlapped_op<Handler> op;
typename op::ptr p = { boost::addressof(handler), typename op::ptr p = { boost::addressof(handler),

View File

@ -136,7 +136,7 @@ public:
// lifetime of the asynchronous operation. // lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_write_some(implementation_type& impl, void async_write_some(implementation_type& impl,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
{ {
handle_service_.async_write_some(impl, buffers, handler); handle_service_.async_write_some(impl, buffers, handler);
} }
@ -153,7 +153,7 @@ public:
// valid for the lifetime of the asynchronous operation. // valid for the lifetime of the asynchronous operation.
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_read_some(implementation_type& impl, void async_read_some(implementation_type& impl,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
{ {
handle_service_.async_read_some(impl, buffers, handler); handle_service_.async_read_some(impl, buffers, handler);
} }

View File

@ -44,7 +44,7 @@ public:
win_iocp_socket_accept_op(win_iocp_socket_service_base& socket_service, win_iocp_socket_accept_op(win_iocp_socket_service_base& socket_service,
socket_type socket, Socket& peer, const Protocol& protocol, socket_type socket, Socket& peer, const Protocol& protocol,
typename Protocol::endpoint* peer_endpoint, typename Protocol::endpoint* peer_endpoint,
bool enable_connection_aborted, Handler handler) bool enable_connection_aborted, Handler& handler)
: operation(&win_iocp_socket_accept_op::do_complete), : operation(&win_iocp_socket_accept_op::do_complete),
socket_service_(socket_service), socket_service_(socket_service),
socket_(socket), socket_(socket),
@ -52,7 +52,7 @@ public:
protocol_(protocol), protocol_(protocol),
peer_endpoint_(peer_endpoint), peer_endpoint_(peer_endpoint),
enable_connection_aborted_(enable_connection_aborted), enable_connection_aborted_(enable_connection_aborted),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -42,12 +42,12 @@ public:
win_iocp_socket_recv_op(socket_ops::state_type state, win_iocp_socket_recv_op(socket_ops::state_type state,
socket_ops::weak_cancel_token_type cancel_token, socket_ops::weak_cancel_token_type cancel_token,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
: operation(&win_iocp_socket_recv_op::do_complete), : operation(&win_iocp_socket_recv_op::do_complete),
state_(state), state_(state),
cancel_token_(cancel_token), cancel_token_(cancel_token),
buffers_(buffers), buffers_(buffers),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -42,13 +42,13 @@ public:
win_iocp_socket_recvfrom_op(Endpoint& endpoint, win_iocp_socket_recvfrom_op(Endpoint& endpoint,
socket_ops::weak_cancel_token_type cancel_token, socket_ops::weak_cancel_token_type cancel_token,
const MutableBufferSequence& buffers, Handler handler) const MutableBufferSequence& buffers, Handler& handler)
: operation(&win_iocp_socket_recvfrom_op::do_complete), : operation(&win_iocp_socket_recvfrom_op::do_complete),
endpoint_(endpoint), endpoint_(endpoint),
endpoint_size_(static_cast<int>(endpoint.capacity())), endpoint_size_(static_cast<int>(endpoint.capacity())),
cancel_token_(cancel_token), cancel_token_(cancel_token),
buffers_(buffers), buffers_(buffers),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -41,11 +41,11 @@ public:
ASIO_DEFINE_HANDLER_PTR(win_iocp_socket_send_op); ASIO_DEFINE_HANDLER_PTR(win_iocp_socket_send_op);
win_iocp_socket_send_op(socket_ops::weak_cancel_token_type cancel_token, win_iocp_socket_send_op(socket_ops::weak_cancel_token_type cancel_token,
const ConstBufferSequence& buffers, Handler handler) const ConstBufferSequence& buffers, Handler& handler)
: operation(&win_iocp_socket_send_op::do_complete), : operation(&win_iocp_socket_send_op::do_complete),
cancel_token_(cancel_token), cancel_token_(cancel_token),
buffers_(buffers), buffers_(buffers),
handler_(handler) handler_(ASIO_MOVE_CAST(Handler)(handler))
{ {
} }

View File

@ -257,7 +257,7 @@ public:
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_send_to(implementation_type& impl, void async_send_to(implementation_type& impl,
const ConstBufferSequence& buffers, const endpoint_type& destination, const ConstBufferSequence& buffers, const endpoint_type& destination,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op; typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
@ -278,7 +278,7 @@ public:
// Start an asynchronous wait until data can be sent without blocking. // Start an asynchronous wait until data can be sent without blocking.
template <typename Handler> template <typename Handler>
void async_send_to(implementation_type& impl, const null_buffers&, void async_send_to(implementation_type& impl, const null_buffers&,
const endpoint_type&, socket_base::message_flags, Handler handler) const endpoint_type&, socket_base::message_flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_null_buffers_op<Handler> op; typedef win_iocp_null_buffers_op<Handler> op;
@ -333,7 +333,7 @@ public:
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_receive_from(implementation_type& impl, void async_receive_from(implementation_type& impl,
const MutableBufferSequence& buffers, endpoint_type& sender_endp, const MutableBufferSequence& buffers, endpoint_type& sender_endp,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_socket_recvfrom_op< typedef win_iocp_socket_recvfrom_op<
@ -355,7 +355,7 @@ public:
template <typename Handler> template <typename Handler>
void async_receive_from(implementation_type& impl, void async_receive_from(implementation_type& impl,
const null_buffers&, endpoint_type& sender_endpoint, const null_buffers&, endpoint_type& sender_endpoint,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_null_buffers_op<Handler> op; typedef win_iocp_null_buffers_op<Handler> op;
@ -404,7 +404,7 @@ public:
// must be valid until the accept's handler is invoked. // must be valid until the accept's handler is invoked.
template <typename Socket, typename Handler> template <typename Socket, typename Handler>
void async_accept(implementation_type& impl, Socket& peer, void async_accept(implementation_type& impl, Socket& peer,
endpoint_type* peer_endpoint, Handler handler) endpoint_type* peer_endpoint, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_socket_accept_op<Socket, protocol_type, Handler> op; typedef win_iocp_socket_accept_op<Socket, protocol_type, Handler> op;
@ -435,7 +435,7 @@ public:
// Start an asynchronous connect. // Start an asynchronous connect.
template <typename Handler> template <typename Handler>
void async_connect(implementation_type& impl, void async_connect(implementation_type& impl,
const endpoint_type& peer_endpoint, Handler handler) const endpoint_type& peer_endpoint, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef reactive_socket_connect_op<Handler> op; typedef reactive_socket_connect_op<Handler> op;

View File

@ -177,7 +177,7 @@ public:
template <typename ConstBufferSequence, typename Handler> template <typename ConstBufferSequence, typename Handler>
void async_send(base_implementation_type& impl, void async_send(base_implementation_type& impl,
const ConstBufferSequence& buffers, const ConstBufferSequence& buffers,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op; typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
@ -198,7 +198,7 @@ public:
// Start an asynchronous wait until data can be sent without blocking. // Start an asynchronous wait until data can be sent without blocking.
template <typename Handler> template <typename Handler>
void async_send(base_implementation_type& impl, const null_buffers&, void async_send(base_implementation_type& impl, const null_buffers&,
socket_base::message_flags, Handler handler) socket_base::message_flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_null_buffers_op<Handler> op; typedef win_iocp_null_buffers_op<Handler> op;
@ -239,7 +239,7 @@ public:
template <typename MutableBufferSequence, typename Handler> template <typename MutableBufferSequence, typename Handler>
void async_receive(base_implementation_type& impl, void async_receive(base_implementation_type& impl,
const MutableBufferSequence& buffers, const MutableBufferSequence& buffers,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_socket_recv_op<MutableBufferSequence, Handler> op; typedef win_iocp_socket_recv_op<MutableBufferSequence, Handler> op;
@ -260,7 +260,7 @@ public:
// Wait until data can be received without blocking. // Wait until data can be received without blocking.
template <typename Handler> template <typename Handler>
void async_receive(base_implementation_type& impl, const null_buffers&, void async_receive(base_implementation_type& impl, const null_buffers&,
socket_base::message_flags flags, Handler handler) socket_base::message_flags flags, Handler& handler)
{ {
// Allocate and construct an operation to wrap the handler. // Allocate and construct an operation to wrap the handler.
typedef win_iocp_null_buffers_op<Handler> op; typedef win_iocp_null_buffers_op<Handler> op;

View File

@ -30,7 +30,7 @@ class wrapped_handler
public: public:
typedef void result_type; typedef void result_type;
wrapped_handler(Dispatcher dispatcher, Handler handler) wrapped_handler(Dispatcher dispatcher, const Handler& handler)
: dispatcher_(dispatcher), : dispatcher_(dispatcher),
handler_(handler) handler_(handler)
{ {

View File

@ -65,14 +65,14 @@ inline bool has_service(io_service& ios)
namespace asio { namespace asio {
template <typename Handler> template <typename CompletionHandler>
inline void io_service::dispatch(Handler handler) inline void io_service::dispatch(CompletionHandler handler)
{ {
impl_.dispatch(handler); impl_.dispatch(handler);
} }
template <typename Handler> template <typename CompletionHandler>
inline void io_service::post(Handler handler) inline void io_service::post(CompletionHandler handler)
{ {
impl_.post(handler); impl_.post(handler);
} }

View File

@ -130,13 +130,13 @@ namespace detail
{ {
public: public:
read_op(AsyncReadStream& stream, const MutableBufferSequence& buffers, read_op(AsyncReadStream& stream, const MutableBufferSequence& buffers,
CompletionCondition completion_condition, ReadHandler handler) CompletionCondition completion_condition, ReadHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
stream_(stream), stream_(stream),
buffers_(buffers), buffers_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -181,13 +181,13 @@ namespace detail
read_op(AsyncReadStream& stream, read_op(AsyncReadStream& stream,
const asio::mutable_buffers_1& buffers, const asio::mutable_buffers_1& buffers,
CompletionCondition completion_condition, CompletionCondition completion_condition,
ReadHandler handler) ReadHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
stream_(stream), stream_(stream),
buffer_(buffers), buffer_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -270,7 +270,10 @@ template <typename AsyncReadStream, typename MutableBufferSequence,
inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
ReadHandler handler) ReadHandler handler)
{ {
async_read(s, buffers, transfer_all(), handler); detail::read_op<AsyncReadStream, MutableBufferSequence,
detail::transfer_all_t, ReadHandler>(
s, buffers, transfer_all(), handler)(
asio::error_code(), 0, 1);
} }
#if !defined(BOOST_NO_IOSTREAM) #if !defined(BOOST_NO_IOSTREAM)
@ -285,13 +288,13 @@ namespace detail
public: public:
read_streambuf_op(AsyncReadStream& stream, read_streambuf_op(AsyncReadStream& stream,
basic_streambuf<Allocator>& streambuf, basic_streambuf<Allocator>& streambuf,
CompletionCondition completion_condition, ReadHandler handler) CompletionCondition completion_condition, ReadHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
stream_(stream), stream_(stream),
streambuf_(streambuf), streambuf_(streambuf),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -374,7 +377,10 @@ template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
inline void async_read(AsyncReadStream& s, inline void async_read(AsyncReadStream& s,
asio::basic_streambuf<Allocator>& b, ReadHandler handler) asio::basic_streambuf<Allocator>& b, ReadHandler handler)
{ {
async_read(s, b, transfer_all(), handler); detail::read_streambuf_op<AsyncReadStream,
Allocator, detail::transfer_all_t, ReadHandler>(
s, b, transfer_all(), handler)(
asio::error_code(), 0, 1);
} }
#endif // !defined(BOOST_NO_IOSTREAM) #endif // !defined(BOOST_NO_IOSTREAM)

View File

@ -141,14 +141,14 @@ namespace detail
public: public:
read_at_op(AsyncRandomAccessReadDevice& device, read_at_op(AsyncRandomAccessReadDevice& device,
boost::uint64_t offset, const MutableBufferSequence& buffers, boost::uint64_t offset, const MutableBufferSequence& buffers,
CompletionCondition completion_condition, ReadHandler handler) CompletionCondition completion_condition, ReadHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
device_(device), device_(device),
offset_(offset), offset_(offset),
buffers_(buffers), buffers_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -194,14 +194,14 @@ namespace detail
public: public:
read_at_op(AsyncRandomAccessReadDevice& device, read_at_op(AsyncRandomAccessReadDevice& device,
boost::uint64_t offset, const asio::mutable_buffers_1& buffers, boost::uint64_t offset, const asio::mutable_buffers_1& buffers,
CompletionCondition completion_condition, ReadHandler handler) CompletionCondition completion_condition, ReadHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
device_(device), device_(device),
offset_(offset), offset_(offset),
buffer_(buffers), buffer_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -289,7 +289,10 @@ inline void async_read_at(AsyncRandomAccessReadDevice& d,
boost::uint64_t offset, const MutableBufferSequence& buffers, boost::uint64_t offset, const MutableBufferSequence& buffers,
ReadHandler handler) ReadHandler handler)
{ {
async_read_at(d, offset, buffers, transfer_all(), handler); detail::read_at_op<AsyncRandomAccessReadDevice,
MutableBufferSequence, detail::transfer_all_t, ReadHandler>(
d, offset, buffers, transfer_all(), handler)(
asio::error_code(), 0, 1);
} }
#if !defined(BOOST_NO_IOSTREAM) #if !defined(BOOST_NO_IOSTREAM)
@ -304,14 +307,14 @@ namespace detail
public: public:
read_at_streambuf_op(AsyncRandomAccessReadDevice& device, read_at_streambuf_op(AsyncRandomAccessReadDevice& device,
boost::uint64_t offset, basic_streambuf<Allocator>& streambuf, boost::uint64_t offset, basic_streambuf<Allocator>& streambuf,
CompletionCondition completion_condition, ReadHandler handler) CompletionCondition completion_condition, ReadHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
device_(device), device_(device),
offset_(offset), offset_(offset),
streambuf_(streambuf), streambuf_(streambuf),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -398,7 +401,10 @@ inline void async_read_at(AsyncRandomAccessReadDevice& d,
boost::uint64_t offset, asio::basic_streambuf<Allocator>& b, boost::uint64_t offset, asio::basic_streambuf<Allocator>& b,
ReadHandler handler) ReadHandler handler)
{ {
async_read_at(d, offset, b, transfer_all(), handler); detail::read_at_streambuf_op<AsyncRandomAccessReadDevice,
Allocator, detail::transfer_all_t, ReadHandler>(
d, offset, b, transfer_all(), handler)(
asio::error_code(), 0, 1);
} }
#endif // !defined(BOOST_NO_IOSTREAM) #endif // !defined(BOOST_NO_IOSTREAM)

View File

@ -325,12 +325,12 @@ namespace detail
public: public:
read_until_delim_op(AsyncReadStream& stream, read_until_delim_op(AsyncReadStream& stream,
asio::basic_streambuf<Allocator>& streambuf, asio::basic_streambuf<Allocator>& streambuf,
char delim, ReadHandler handler) char delim, ReadHandler& handler)
: stream_(stream), : stream_(stream),
streambuf_(streambuf), streambuf_(streambuf),
delim_(delim), delim_(delim),
search_position_(0), search_position_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -458,12 +458,12 @@ namespace detail
public: public:
read_until_delim_string_op(AsyncReadStream& stream, read_until_delim_string_op(AsyncReadStream& stream,
asio::basic_streambuf<Allocator>& streambuf, asio::basic_streambuf<Allocator>& streambuf,
const std::string& delim, ReadHandler handler) const std::string& delim, ReadHandler& handler)
: stream_(stream), : stream_(stream),
streambuf_(streambuf), streambuf_(streambuf),
delim_(delim), delim_(delim),
search_position_(0), search_position_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -604,12 +604,12 @@ namespace detail
public: public:
read_until_expr_op(AsyncReadStream& stream, read_until_expr_op(AsyncReadStream& stream,
asio::basic_streambuf<Allocator>& streambuf, asio::basic_streambuf<Allocator>& streambuf,
const boost::regex& expr, ReadHandler handler) const boost::regex& expr, ReadHandler& handler)
: stream_(stream), : stream_(stream),
streambuf_(streambuf), streambuf_(streambuf),
expr_(expr), expr_(expr),
search_position_(0), search_position_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }
@ -755,12 +755,12 @@ namespace detail
public: public:
read_until_match_op(AsyncReadStream& stream, read_until_match_op(AsyncReadStream& stream,
asio::basic_streambuf<Allocator>& streambuf, asio::basic_streambuf<Allocator>& streambuf,
MatchCondition match_condition, ReadHandler handler) MatchCondition match_condition, ReadHandler& handler)
: stream_(stream), : stream_(stream),
streambuf_(streambuf), streambuf_(streambuf),
match_condition_(match_condition), match_condition_(match_condition),
search_position_(0), search_position_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
{ {
} }

View File

@ -116,13 +116,13 @@ namespace detail
{ {
public: public:
write_op(AsyncWriteStream& stream, const ConstBufferSequence& buffers, write_op(AsyncWriteStream& stream, const ConstBufferSequence& buffers,
CompletionCondition completion_condition, WriteHandler handler) CompletionCondition completion_condition, WriteHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
stream_(stream), stream_(stream),
buffers_(buffers), buffers_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -167,13 +167,13 @@ namespace detail
write_op(AsyncWriteStream& stream, write_op(AsyncWriteStream& stream,
const asio::mutable_buffers_1& buffers, const asio::mutable_buffers_1& buffers,
CompletionCondition completion_condition, CompletionCondition completion_condition,
WriteHandler handler) WriteHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
stream_(stream), stream_(stream),
buffer_(buffers), buffer_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -218,13 +218,13 @@ namespace detail
write_op(AsyncWriteStream& stream, write_op(AsyncWriteStream& stream,
const asio::const_buffers_1& buffers, const asio::const_buffers_1& buffers,
CompletionCondition completion_condition, CompletionCondition completion_condition,
WriteHandler handler) WriteHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
stream_(stream), stream_(stream),
buffer_(buffers), buffer_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -307,7 +307,10 @@ template <typename AsyncWriteStream, typename ConstBufferSequence,
inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
WriteHandler handler) WriteHandler handler)
{ {
async_write(s, buffers, transfer_all(), handler); detail::write_op<AsyncWriteStream, ConstBufferSequence,
detail::transfer_all_t, WriteHandler>(
s, buffers, transfer_all(), handler)(
asio::error_code(), 0, 1);
} }
#if !defined(BOOST_NO_IOSTREAM) #if !defined(BOOST_NO_IOSTREAM)
@ -320,9 +323,9 @@ namespace detail
{ {
public: public:
write_streambuf_handler(asio::basic_streambuf<Allocator>& streambuf, write_streambuf_handler(asio::basic_streambuf<Allocator>& streambuf,
WriteHandler handler) WriteHandler& handler)
: streambuf_(streambuf), : streambuf_(streambuf),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -384,7 +387,9 @@ template <typename AsyncWriteStream, typename Allocator, typename WriteHandler>
inline void async_write(AsyncWriteStream& s, inline void async_write(AsyncWriteStream& s,
asio::basic_streambuf<Allocator>& b, WriteHandler handler) asio::basic_streambuf<Allocator>& b, WriteHandler handler)
{ {
async_write(s, b, transfer_all(), handler); async_write(s, b.data(), transfer_all(),
detail::write_streambuf_handler<
AsyncWriteStream, Allocator, WriteHandler>(b, handler));
} }
#endif // !defined(BOOST_NO_IOSTREAM) #endif // !defined(BOOST_NO_IOSTREAM)

View File

@ -125,14 +125,14 @@ namespace detail
public: public:
write_at_op(AsyncRandomAccessWriteDevice& device, write_at_op(AsyncRandomAccessWriteDevice& device,
boost::uint64_t offset, const ConstBufferSequence& buffers, boost::uint64_t offset, const ConstBufferSequence& buffers,
CompletionCondition completion_condition, WriteHandler handler) CompletionCondition completion_condition, WriteHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
device_(device), device_(device),
offset_(offset), offset_(offset),
buffers_(buffers), buffers_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -179,14 +179,14 @@ namespace detail
write_at_op(AsyncRandomAccessWriteDevice& device, write_at_op(AsyncRandomAccessWriteDevice& device,
boost::uint64_t offset, const asio::mutable_buffers_1& buffers, boost::uint64_t offset, const asio::mutable_buffers_1& buffers,
CompletionCondition completion_condition, CompletionCondition completion_condition,
WriteHandler handler) WriteHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
device_(device), device_(device),
offset_(offset), offset_(offset),
buffer_(buffers), buffer_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -232,14 +232,14 @@ namespace detail
write_at_op(AsyncRandomAccessWriteDevice& device, write_at_op(AsyncRandomAccessWriteDevice& device,
boost::uint64_t offset, const asio::const_buffers_1& buffers, boost::uint64_t offset, const asio::const_buffers_1& buffers,
CompletionCondition completion_condition, CompletionCondition completion_condition,
WriteHandler handler) WriteHandler& handler)
: detail::base_from_completion_cond< : detail::base_from_completion_cond<
CompletionCondition>(completion_condition), CompletionCondition>(completion_condition),
device_(device), device_(device),
offset_(offset), offset_(offset),
buffer_(buffers), buffer_(buffers),
total_transferred_(0), total_transferred_(0),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -325,7 +325,10 @@ inline void async_write_at(AsyncRandomAccessWriteDevice& d,
boost::uint64_t offset, const ConstBufferSequence& buffers, boost::uint64_t offset, const ConstBufferSequence& buffers,
WriteHandler handler) WriteHandler handler)
{ {
async_write_at(d, offset, buffers, transfer_all(), handler); detail::write_at_op<AsyncRandomAccessWriteDevice,
ConstBufferSequence, detail::transfer_all_t, WriteHandler>(
d, offset, buffers, transfer_all(), handler)(
asio::error_code(), 0, 1);
} }
#if !defined(BOOST_NO_IOSTREAM) #if !defined(BOOST_NO_IOSTREAM)
@ -339,9 +342,9 @@ namespace detail
public: public:
write_at_streambuf_op( write_at_streambuf_op(
asio::basic_streambuf<Allocator>& streambuf, asio::basic_streambuf<Allocator>& streambuf,
WriteHandler handler) WriteHandler& handler)
: streambuf_(streambuf), : streambuf_(streambuf),
handler_(handler) handler_(ASIO_MOVE_CAST(WriteHandler)(handler))
{ {
} }
@ -405,7 +408,9 @@ inline void async_write_at(AsyncRandomAccessWriteDevice& d,
boost::uint64_t offset, asio::basic_streambuf<Allocator>& b, boost::uint64_t offset, asio::basic_streambuf<Allocator>& b,
WriteHandler handler) WriteHandler handler)
{ {
async_write_at(d, offset, b, transfer_all(), handler); async_write_at(d, offset, b.data(), transfer_all(),
detail::write_at_streambuf_op<
AsyncRandomAccessWriteDevice, Allocator, WriteHandler>(b, handler));
} }
#endif // !defined(BOOST_NO_IOSTREAM) #endif // !defined(BOOST_NO_IOSTREAM)

View File

@ -153,7 +153,8 @@ public:
template <typename ResolveHandler> template <typename ResolveHandler>
void async_resolve(const query& q, ResolveHandler handler) void async_resolve(const query& q, ResolveHandler handler)
{ {
return this->service.async_resolve(this->implementation, q, handler); return this->service.async_resolve(this->implementation, q,
ASIO_MOVE_CAST(ResolveHandler)(handler));
} }
/// Perform reverse resolution of an endpoint to a list of entries. /// Perform reverse resolution of an endpoint to a list of entries.
@ -237,7 +238,8 @@ public:
template <typename ResolveHandler> template <typename ResolveHandler>
void async_resolve(const endpoint_type& e, ResolveHandler handler) void async_resolve(const endpoint_type& e, ResolveHandler handler)
{ {
return this->service.async_resolve(this->implementation, e, handler); return this->service.async_resolve(this->implementation, e,
ASIO_MOVE_CAST(ResolveHandler)(handler));
} }
}; };

View File

@ -183,7 +183,8 @@ public:
void async_write_some(const ConstBufferSequence& buffers, void async_write_some(const ConstBufferSequence& buffers,
WriteHandler handler) WriteHandler handler)
{ {
this->service.async_write_some(this->implementation, buffers, handler); this->service.async_write_some(this->implementation, buffers,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Read some data from the descriptor. /// Read some data from the descriptor.
@ -287,7 +288,8 @@ public:
void async_read_some(const MutableBufferSequence& buffers, void async_read_some(const MutableBufferSequence& buffers,
ReadHandler handler) ReadHandler handler)
{ {
this->service.async_read_some(this->implementation, buffers, handler); this->service.async_read_some(this->implementation, buffers,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };

View File

@ -138,8 +138,8 @@ public:
* handler object as required. The function signature of the handler must be: * handler object as required. The function signature of the handler must be:
* @code void handler(); @endcode * @code void handler(); @endcode
*/ */
template <typename Handler> template <typename CompletionHandler>
void dispatch(Handler handler) void dispatch(CompletionHandler handler)
{ {
service_.dispatch(impl_, handler); service_.dispatch(impl_, handler);
} }
@ -160,8 +160,8 @@ public:
* handler object as required. The function signature of the handler must be: * handler object as required. The function signature of the handler must be:
* @code void handler(); @endcode * @code void handler(); @endcode
*/ */
template <typename Handler> template <typename CompletionHandler>
void post(Handler handler) void post(CompletionHandler handler)
{ {
service_.post(impl_, handler); service_.post(impl_, handler);
} }

View File

@ -188,8 +188,8 @@ public:
void async_write_some_at(boost::uint64_t offset, void async_write_some_at(boost::uint64_t offset,
const ConstBufferSequence& buffers, WriteHandler handler) const ConstBufferSequence& buffers, WriteHandler handler)
{ {
this->service.async_write_some_at( this->service.async_write_some_at(this->implementation,
this->implementation, offset, buffers, handler); offset, buffers, ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Read some data from the handle at the specified offset. /// Read some data from the handle at the specified offset.
@ -302,8 +302,8 @@ public:
void async_read_some_at(boost::uint64_t offset, void async_read_some_at(boost::uint64_t offset,
const MutableBufferSequence& buffers, ReadHandler handler) const MutableBufferSequence& buffers, ReadHandler handler)
{ {
this->service.async_read_some_at( this->service.async_read_some_at(this->implementation,
this->implementation, offset, buffers, handler); offset, buffers, ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };

View File

@ -181,7 +181,8 @@ public:
void async_write_some(const ConstBufferSequence& buffers, void async_write_some(const ConstBufferSequence& buffers,
WriteHandler handler) WriteHandler handler)
{ {
this->service.async_write_some(this->implementation, buffers, handler); this->service.async_write_some(this->implementation, buffers,
ASIO_MOVE_CAST(WriteHandler)(handler));
} }
/// Read some data from the handle. /// Read some data from the handle.
@ -285,7 +286,8 @@ public:
void async_read_some(const MutableBufferSequence& buffers, void async_read_some(const MutableBufferSequence& buffers,
ReadHandler handler) ReadHandler handler)
{ {
this->service.async_read_some(this->implementation, buffers, handler); this->service.async_read_some(this->implementation, buffers,
ASIO_MOVE_CAST(ReadHandler)(handler));
} }
}; };