Remove obsolete handler wrappers

This commit is contained in:
Vinnie Falco
2013-08-18 02:29:48 -07:00
parent 04b5c7f447
commit 2d04fc4641
7 changed files with 270 additions and 398 deletions

View File

@@ -156,15 +156,22 @@ public:
HandlerCall will meet this requirement:
CompletionHandler
*/
/** @{ */
template <typename Handler>
HandlerCall (BOOST_ASIO_MOVE_ARG(Handler) handler, Completion,
Context context = Context ())
: m_call (construct <PostCallType> (
BOOST_ASIO_MOVE_CAST(Handler)(handler),
context))
HandlerCall (Post, BOOST_ASIO_MOVE_ARG(Handler) handler)
: m_call (construct <PostCallType> (Context (),
BOOST_ASIO_MOVE_CAST(Handler)(handler)))
{
}
template <typename Handler>
HandlerCall (Post, Context context, BOOST_ASIO_MOVE_ARG(Handler) handler)
: m_call (construct <PostCallType> (context,
BOOST_ASIO_MOVE_CAST(Handler)(handler)))
{
}
/** @} */
/** Construct a HandlerCall with one bound parameter.
Produce a CompletionHandler that includes one bound parameter.
@@ -189,15 +196,22 @@ public:
HandlerCall will meet this requirement:
CompletionHandler
*/
/** @{ */
template <typename Handler, typename Arg1>
HandlerCall (BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1, Completion,
Context context = Context ())
: m_call (construct <PostCallType1> (
BOOST_ASIO_MOVE_CAST(Handler)(handler),
context, arg1))
HandlerCall (Post, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1)
: m_call (construct <PostCallType1> (Context (),
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1))
{
}
template <typename Handler, typename Arg1>
HandlerCall (Post, Context context, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1)
: m_call (construct <PostCallType1> (context,
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1))
{
}
/** @} */
/** Construct a HandlerCall with two bound parameters.
Produce a CompletionHandler that includes two bound parameters.
@@ -221,15 +235,22 @@ public:
The HandlerCall will meet these requirements:
CompletionHandler
*/
/** @{ */
template <typename Handler, typename Arg1, typename Arg2>
HandlerCall (BOOST_ASIO_MOVE_ARG(Handler) handler,
Arg1 arg1, Arg2 arg2, Completion, Context context = Context ())
: m_call (construct <PostCallType2> (
BOOST_ASIO_MOVE_CAST(Handler)(handler),
context, arg1, arg2))
HandlerCall (Post, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1, Arg2 arg2)
: m_call (construct <PostCallType2> (Context (),
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2))
{
}
template <typename Handler, typename Arg1, typename Arg2>
HandlerCall (Post, Context context, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1, Arg2 arg2)
: m_call (construct <PostCallType2> (context,
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2))
{
}
/** @} */
/** Construct a HandlerCall from a handler that takes an error_code
Handler must meet one of these requirements:
@@ -244,15 +265,22 @@ public:
ShutdownHandler
HandshakeHandler
*/
/** @{ */
template <typename Handler>
HandlerCall (BOOST_ASIO_MOVE_ARG(Handler) handler, Error,
Context context = Context ())
: m_call (construct <ErrorCallType> (
BOOST_ASIO_MOVE_CAST(Handler)(handler),
context))
HandlerCall (Error, BOOST_ASIO_MOVE_ARG(Handler) handler)
: m_call (construct <ErrorCallType> (Context (),
BOOST_ASIO_MOVE_CAST(Handler)(handler)))
{
}
template <typename Handler>
HandlerCall (Error, Context context, BOOST_ASIO_MOVE_ARG(Handler) handler)
: m_call (construct <ErrorCallType> (context,
BOOST_ASIO_MOVE_CAST(Handler)(handler)))
{
}
/** @} */
/** Construct a HandlerCall from a handler that takes an error_code and std::size
Handler must meet one of these requirements:
@@ -265,15 +293,22 @@ public:
WriteHandler
BufferedHandshakeHandler
*/
/** @{ */
template <typename Handler>
HandlerCall (BOOST_ASIO_MOVE_ARG(Handler) handler, Transfer,
Context context = Context ())
: m_call (construct <TransferCallType> (
BOOST_ASIO_MOVE_CAST(Handler)(handler),
context))
HandlerCall (Transfer, BOOST_ASIO_MOVE_ARG(Handler) handler)
: m_call (construct <TransferCallType> (Context (),
BOOST_ASIO_MOVE_CAST(Handler)(handler)))
{
}
template <typename Handler>
HandlerCall (Transfer, Context context, BOOST_ASIO_MOVE_ARG(Handler) handler)
: m_call (construct <TransferCallType> (context,
BOOST_ASIO_MOVE_CAST(Handler)(handler)))
{
}
/** @} */
/** Copy construction and assignment.
HandlerCall is a very lightweight object that holds a shared
@@ -532,46 +567,41 @@ private:
// ownership of the handler from the stack.
template <template <typename> class Container, typename Handler>
static Call* construct (BOOST_ASIO_MOVE_ARG(Handler) handler,
Context context)
static Call* construct (Context context, BOOST_ASIO_MOVE_ARG(Handler) handler)
{
typedef Container <Handler> ContainerType;
Handler local (BOOST_ASIO_MOVE_CAST(Handler)(handler));
std::size_t const size (sizeof (ContainerType));
void* const p = boost_asio_handler_alloc_helpers::
allocate <Handler> (size, local);
return ::new (p) ContainerType (
BOOST_ASIO_MOVE_CAST(Handler)(local), size, context);
return ::new (p) ContainerType (context, size,
BOOST_ASIO_MOVE_CAST(Handler)(local));
}
template <template <typename, typename> class Container,
typename Handler, typename Arg1>
static Call* construct (BOOST_ASIO_MOVE_ARG(Handler) handler,
Context context, Arg1 arg1)
static Call* construct (Context context, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1)
{
typedef Container <Handler, Arg1> ContainerType;
Handler local (BOOST_ASIO_MOVE_CAST(Handler)(handler));
std::size_t const size (sizeof (ContainerType));
void* const p = boost_asio_handler_alloc_helpers::
allocate <Handler> (size, local);
return ::new (p) ContainerType (
BOOST_ASIO_MOVE_CAST(Handler)(local),
size, context, arg1);
return ::new (p) ContainerType (context, size,
BOOST_ASIO_MOVE_CAST(Handler)(local), arg1);
}
template <template <typename, typename, typename> class Container,
typename Handler, typename Arg1, typename Arg2>
static Call* construct (BOOST_ASIO_MOVE_ARG(Handler) handler,
Context context, Arg1 arg1, Arg2 arg2)
static Call* construct (Context context, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1, Arg2 arg2)
{
typedef Container <Handler, Arg1, Arg2> ContainerType;
Handler local (BOOST_ASIO_MOVE_CAST(Handler)(handler));
std::size_t const size (sizeof (ContainerType));
void* const p = boost_asio_handler_alloc_helpers::
allocate <Handler> (size, local);
return ::new (p) ContainerType (
BOOST_ASIO_MOVE_CAST(Handler)(local),
size, context, arg1, arg2);
return ::new (p) ContainerType (context, size,
BOOST_ASIO_MOVE_CAST(Handler)(local), arg1, arg2);
}
//--------------------------------------------------------------------------
@@ -734,8 +764,7 @@ private:
// Context must have Call as a base or this will result in
// undefined behavior.
//
CallType (BOOST_ASIO_MOVE_ARG(Handler) handler,
std::size_t size, Context context)
CallType (Context context, std::size_t size, BOOST_ASIO_MOVE_ARG(Handler) handler)
: Call (context)
, m_size (size)
, m_handler (BOOST_ASIO_MOVE_CAST(Handler)(handler))
@@ -833,10 +862,8 @@ private:
template <typename Handler>
struct PostCallType : CallType <Handler>
{
PostCallType (BOOST_ASIO_MOVE_ARG(Handler) handler,
std::size_t size, Context context)
: CallType <Handler> (BOOST_ASIO_MOVE_CAST(Handler)(handler),
size, context)
PostCallType (Context context, std::size_t size, BOOST_ASIO_MOVE_ARG(Handler) handler)
: CallType <Handler> (context, size, BOOST_ASIO_MOVE_CAST(Handler)(handler))
{
}
@@ -849,10 +876,8 @@ private:
template <typename Handler, typename Arg1>
struct PostCallType1 : CallType <Handler>
{
PostCallType1 (BOOST_ASIO_MOVE_ARG(Handler) handler,
std::size_t size, Context context, Arg1 arg1)
: CallType <Handler> (BOOST_ASIO_MOVE_CAST(Handler)(handler),
size, context)
PostCallType1 (Context context, std::size_t size, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1)
: CallType <Handler> (context, size, BOOST_ASIO_MOVE_CAST(Handler)(handler))
, m_arg1 (arg1)
{
}
@@ -868,10 +893,8 @@ private:
template <typename Handler, typename Arg1, typename Arg2>
struct PostCallType2 : CallType <Handler>
{
PostCallType2 (BOOST_ASIO_MOVE_ARG(Handler) handler,
std::size_t size, Context context, Arg1 arg1, Arg2 arg2)
: CallType <Handler> (BOOST_ASIO_MOVE_CAST(Handler)(handler),
size, context)
PostCallType2 (Context context, std::size_t size, BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1, Arg2 arg2)
: CallType <Handler> (context, size, BOOST_ASIO_MOVE_CAST(Handler)(handler))
, m_arg1 (arg1)
, m_arg2 (arg2)
{
@@ -889,10 +912,8 @@ private:
template <typename Handler>
struct ErrorCallType : CallType <Handler>
{
ErrorCallType (BOOST_ASIO_MOVE_ARG(Handler) handler,
std::size_t size, Context context)
: CallType <Handler> (BOOST_ASIO_MOVE_CAST(Handler)(handler),
size, context)
ErrorCallType (Context context, std::size_t size, BOOST_ASIO_MOVE_ARG(Handler) handler)
: CallType <Handler> (context, size, BOOST_ASIO_MOVE_CAST(Handler)(handler))
{
}
@@ -905,10 +926,8 @@ private:
template <typename Handler>
struct TransferCallType : CallType <Handler>
{
TransferCallType (BOOST_ASIO_MOVE_ARG(Handler) handler,
std::size_t size, Context context)
: CallType <Handler> (BOOST_ASIO_MOVE_CAST(Handler)(handler),
size, context)
TransferCallType (Context context, std::size_t size, BOOST_ASIO_MOVE_ARG(Handler) handler)
: CallType <Handler> (context, size, BOOST_ASIO_MOVE_CAST(Handler)(handler))
{
}
@@ -936,65 +955,6 @@ private:
SharedObjectPtr <Call> m_call;
};
//------------------------------------------------------------------------------
class CompletionCall : public HandlerCall
{
public:
CompletionCall ()
{
}
template <typename Handler>
explicit CompletionCall (BOOST_ASIO_MOVE_ARG(Handler) handler)
: HandlerCall (BOOST_ASIO_MOVE_CAST(Handler)(handler), HandlerCall::Post ())
{
}
template <typename Handler, typename Arg1>
explicit CompletionCall (BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1)
: HandlerCall (BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, HandlerCall::Post ())
{
}
template <typename Handler, typename Arg1, typename Arg2>
explicit CompletionCall (BOOST_ASIO_MOVE_ARG(Handler) handler, Arg1 arg1, Arg2 arg2)
: HandlerCall (BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, HandlerCall::Post ())
{
}
};
//------------------------------------------------------------------------------
class ErrorCall : public HandlerCall
{
public:
ErrorCall ()
{
}
template <typename Handler>
explicit ErrorCall (BOOST_ASIO_MOVE_ARG(Handler) handler)
: HandlerCall (BOOST_ASIO_MOVE_CAST(Handler)(handler), HandlerCall::Error ())
{
}
};
//------------------------------------------------------------------------------
class TransferCall : public HandlerCall
{
public:
TransferCall ()
{
}
template <typename Handler>
explicit TransferCall (BOOST_ASIO_MOVE_ARG(Handler) handler)
: HandlerCall (BOOST_ASIO_MOVE_CAST(Handler)(handler), HandlerCall::Transfer ())
{
}
};
//------------------------------------------------------------------------------
//
// Specializations

View File

@@ -60,13 +60,7 @@ public:
virtual void on_async_detect (Logic& logic,
error_code const& ec, ConstBuffers const& buffers,
ErrorCall const& origHandler) = 0;
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
virtual void on_async_detect (Logic& logic,
error_code const& ec, ConstBuffers const& buffers,
TransferCall const& origHandler) = 0;
#endif
HandlerCall const& origHandler) = 0;
};
};
@@ -149,49 +143,18 @@ public:
HandshakeHandler, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));
// init.handler is copied
m_origHandler = ErrorCall (
m_origHandler = HandlerCall (
BOOST_ASIO_MOVE_CAST(HandshakeHandler)
(HandshakeHandler(init.handler)));
async_do_handshake (type, ConstBuffers ());
return init.result.get();
#else
m_origHandler = ErrorCall (
m_origHandler = HandlerCall (
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));
async_do_handshake (type, ConstBuffers ());
#endif
}
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
template <typename ConstBufferSequence>
error_code handshake (handshake_type type,
const ConstBufferSequence& buffers, error_code& ec)
{
return do_handshake (type, ec, ConstBuffers (buffers));
}
template <typename ConstBufferSequence, typename BufferedHandshakeHandler>
BEAST_ASIO_INITFN_RESULT_TYPE(BufferedHandshakeHandler, void (error_code, std::size_t))
async_handshake(handshake_type type, const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
BufferedHandshakeHandler, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)(handler));
// init.handler is copied
m_origBufferedHandler = TransferCall (
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)
(BufferedHandshakeHandler(init.handler)));
async_do_handshake (type, ConstBuffers (buffers));
return init.result.get();
#else
m_origBufferedHandler = TransferCall (
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler(handler)));
async_do_handshake (type, ConstBuffers (buffers));
#endif
}
#endif
//--------------------------------------------------------------------------
error_code do_handshake (handshake_type, error_code& ec, ConstBuffers const& buffers)
@@ -244,16 +207,8 @@ public:
// Get the execution context from the original handler
// and signal the beginning of our composed operation.
//
if (m_origHandler.isNotNull ())
{
m_origHandler.beginComposed ();
m_context = m_origHandler.getContext ();
}
else
{
m_origBufferedHandler.beginComposed ();
m_context = m_origBufferedHandler.getContext ();
}
bassert (m_context.isNotNull ());
@@ -288,22 +243,6 @@ public:
bassert (consumed <= m_buffer.size ());
m_buffer.consume (consumed);
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
if (! m_origBufferedHandler.isNull ())
{
bassert (m_origHandler.isNull ());
// The composed operation has completed and
// the original handler will eventually get called.
//
m_origBufferedHandler.endComposed ();
m_callback->on_async_detect (m_logic.get (), ec,
ConstBuffers (m_buffer.data ()), m_origBufferedHandler);
return;
}
#endif
// The composed operation has completed and
// the original handler will eventually get called.
//
@@ -323,11 +262,10 @@ public:
// of the original handler. This ensures that we meet the
// execution safety requirements of the handler.
//
HandlerCall handler (boost::bind (
&this_type::on_async_read_some, this,
HandlerCall handler (HandlerCall::Read (), m_context,
boost::bind (&this_type::on_async_read_some, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred),
HandlerCall::Read (), m_context);
boost::asio::placeholders::bytes_transferred));
m_next_layer.async_read_some (buffers, handler);
return;
@@ -335,17 +273,7 @@ public:
// Error condition
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
if (! m_origBufferedHandler.isNull ())
{
m_origBufferedHandler.endComposed ();
m_callback->on_async_detect (m_logic.get (), ec,
ConstBuffers (m_buffer.data ()), m_origBufferedHandler);
return;
}
#endif
m_origBufferedHandler.endComposed ();
m_origHandler.endComposed ();
m_callback->on_async_detect (m_logic.get (), ec,
ConstBuffers (m_buffer.data ()), m_origHandler);
}
@@ -356,8 +284,8 @@ private:
buffer_type m_buffer;
boost::asio::buffered_read_stream <stream_type&> m_stream;
HandshakeDetectLogicType <Logic> m_logic;
ErrorCall m_origHandler;
TransferCall m_origBufferedHandler;
HandlerCall m_origHandler;
HandlerCall m_origBufferedHandler;
HandlerCall::Context m_context;
};
/** @} */

View File

@@ -74,23 +74,23 @@ boost::system::error_code Socket::accept (Socket&, boost::system::error_code& ec
return pure_virtual (ec);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (boost::system::error_code))
Socket::async_accept (Socket&, BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (boost::system::error_code))
Socket::async_accept (Socket&, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
ErrorCall, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
HandlerCall, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
return init.result.get();
#else
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
#endif
}
@@ -111,41 +111,41 @@ std::size_t Socket::write_some (ConstBuffers const&, boost::system::error_code&
return 0;
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (boost::system::error_code, std::size_t))
Socket::async_read_some (MutableBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (boost::system::error_code, std::size_t))
Socket::async_read_some (MutableBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
TransferCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
HandlerCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
get_io_service ().post (boost::bind (BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec, 0));
return init.result.get();
#else
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
get_io_service ().post (boost::bind (BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec, 0));
#endif
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (boost::system::error_code, std::size_t))
Socket::async_write_some (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (boost::system::error_code, std::size_t))
Socket::async_write_some (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
TransferCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
HandlerCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec, 0));
return init.result.get();
#else
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec, 0));
#endif
}
@@ -164,23 +164,23 @@ boost::system::error_code Socket::handshake (handshake_type, boost::system::erro
return pure_virtual (ec);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (boost::system::error_code))
Socket::async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (boost::system::error_code))
Socket::async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
ErrorCall, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
HandlerCall, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
return init.result.get();
#else
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
#endif
}
@@ -192,24 +192,24 @@ boost::system::error_code Socket::handshake (handshake_type,
return pure_virtual (ec);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (boost::system::error_code, std::size_t))
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (boost::system::error_code, std::size_t))
Socket::async_handshake (handshake_type, ConstBuffers const&,
BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
TransferCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
HandlerCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec, 0));
return init.result.get();
#else
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), ec, 0));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec, 0));
#endif
}
@@ -220,23 +220,23 @@ boost::system::error_code Socket::shutdown (boost::system::error_code& ec)
return pure_virtual (ec);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (boost::system::error_code))
Socket::async_shutdown (BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (boost::system::error_code))
Socket::async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
ErrorCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
HandlerCall, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
return init.result.get();
#else
boost::system::error_code ec;
ec = pure_virtual (ec);
get_io_service ().post (boost::bind (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
#endif
}

View File

@@ -169,13 +169,13 @@ public:
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
{
return async_accept (peer,
BOOST_ASIO_MOVE_CAST(ErrorCall)(ErrorCall (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Accept (),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler))));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(ErrorCall) handler);
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
//--------------------------------------------------------------------------
//
@@ -210,13 +210,13 @@ public:
async_read_some (MutableBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
return async_read_some (MutableBuffers (buffers),
BOOST_ASIO_MOVE_CAST(TransferCall)(TransferCall (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler);
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
// AsyncWriteStream
// http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/AsyncWriteStream.html
@@ -225,13 +225,13 @@ public:
async_write_some (ConstBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
return async_write_some (ConstBuffers (buffers),
BOOST_ASIO_MOVE_CAST(TransferCall)(TransferCall (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler);
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
//--------------------------------------------------------------------------
//
@@ -275,13 +275,13 @@ public:
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler)
{
return async_handshake (type,
BOOST_ASIO_MOVE_CAST(ErrorCall)(ErrorCall (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Error (),
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler))));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(ErrorCall) handler);
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
//--------------------------------------------------------------------------
@@ -318,14 +318,14 @@ public:
BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler)
{
return async_handshake (type, ConstBuffers (buffers),
BOOST_ASIO_MOVE_CAST(TransferCall)(TransferCall (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)(handler))));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_handshake (handshake_type type, ConstBuffers const& buffers,
BOOST_ASIO_MOVE_ARG(TransferCall) handler);
BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
#endif
//--------------------------------------------------------------------------
@@ -348,13 +348,13 @@ public:
void async_shutdown (BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler)
{
return async_shutdown (
BOOST_ASIO_MOVE_CAST(ErrorCall)(ErrorCall (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Error (),
BOOST_ASIO_MOVE_CAST(ShutdownHandler)(handler))));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(ErrorCall) handler);
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
};
#endif

View File

@@ -363,19 +363,19 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
using namespace SocketWrapperMemberChecks;
typedef typename native_socket <this_layer_type>::socket_type socket_type;
return async_accept (peer, BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
return async_accept (peer, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
EnableIf <has_async_accept <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
(socket_type&, BOOST_ASIO_MOVE_ARG(TransferCall))>::value> ());
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
(socket_type&, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
}
template <typename AcceptHandler>
BEAST_ASIO_INITFN_RESULT_TYPE(ErrorCall, void (error_code))
BEAST_ASIO_INITFN_RESULT_TYPE(HandlerCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
boost::true_type)
{
@@ -395,12 +395,12 @@ public:
AcceptHandler, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
// init.handler is copied
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (HandlerCall::Post (),
AcceptHandler (init.handler), pure_virtual_error ()));
return init.result.get();
#else
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler),
pure_virtual_error ()));
@@ -462,14 +462,14 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
using namespace SocketWrapperMemberChecks;
return async_read_some (buffers, BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
return async_read_some (buffers, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
EnableIf <has_async_read_some <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
(MutableBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall))>::value> ());
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
(MutableBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
}
template <typename MutableBufferSequence, typename ReadHandler>
@@ -491,12 +491,12 @@ public:
ReadHandler, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
// init.handler is copied
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (HandlerCall::Post (),
ReadHandler (init.handler), pure_virtual_error (), 0));
return init.result.get();
#else
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler),
pure_virtual_error (), 0));
@@ -505,40 +505,40 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
using namespace SocketWrapperMemberChecks;
return async_write_some (buffers, BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
return async_write_some (buffers, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
EnableIf <has_async_write_some <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
(ConstBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall))>::value> ());
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
(ConstBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::true_type)
{
return m_object.async_write_some (buffers,
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
TransferCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
HandlerCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
get_io_service ().post (CompletionCall (
TransferCall (init.handler), pure_virtual_error (), 0));
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error (), 0));
return init.result.get();
#else
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error (), 0));
#endif
@@ -556,8 +556,8 @@ public:
has_handshake <this_layer_type,
error_code (handshake_type, error_code&)>::value ||
has_async_handshake <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
(handshake_type, BOOST_ASIO_MOVE_ARG(ErrorCall))>::value;
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
(handshake_type, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value;
}
//--------------------------------------------------------------------------
@@ -584,39 +584,39 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
using namespace SocketWrapperMemberChecks;
return async_handshake (type, BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
return async_handshake (type, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
EnableIf <has_async_handshake <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
(handshake_type, BOOST_ASIO_MOVE_ARG(ErrorCall))>::value> ());
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
(handshake_type, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(ErrorCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::true_type)
{
return m_object.async_handshake (type,
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(ErrorCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
ErrorCall, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
HandlerCall, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
get_io_service ().post (CompletionCall (
ErrorCall (init.handler), pure_virtual_error ()));
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error ()));
return init.result.get();
#else
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error ()));
#endif
}
@@ -647,41 +647,41 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_handshake (handshake_type type, ConstBuffers const& buffers,
BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
using namespace SocketWrapperMemberChecks;
return async_handshake (type, buffers, BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
return async_handshake (type, buffers, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
EnableIf <has_async_handshake <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
(handshake_type, ConstBuffers const&, error_code&)>::value> ());
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_handshake (handshake_type type, ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_handshake (handshake_type type, ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::true_type)
{
return m_object.async_handshake (type, buffers,
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_handshake (handshake_type, ConstBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_handshake (handshake_type, ConstBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
TransferCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
HandlerCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
get_io_service ().post (CompletionCall (
TransferCall (init.handler), pure_virtual_error (), 0));
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error (), 0));
return init.result.get();
#else
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler),
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error (), 0));
#endif
@@ -713,39 +713,39 @@ public:
//--------------------------------------------------------------------------
void async_shutdown (BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
void async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
using namespace SocketWrapperMemberChecks;
return async_shutdown (BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
return async_shutdown (BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
EnableIf <has_async_shutdown <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
(BOOST_ASIO_MOVE_ARG(ErrorCall))>::value> ());
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
(BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(ErrorCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::true_type)
{
return m_object.async_shutdown (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(ErrorCall) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
ErrorCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
HandlerCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
get_io_service ().post (CompletionCall (
ErrorCall (init.handler), pure_virtual_error ()));
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error ()));
return init.result.get();
#else
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error ()));
#endif

View File

@@ -159,14 +159,14 @@ public:
ReadHandler, void (error_code, std::size_t)> init (
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (HandlerCall::Post (),
ReadHandler(init.handler), // handler is copied
error_code (), bytes_transferred));
return init.result.get();
#else
return get_io_service ().post (CompletionCall (
return get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler),
error_code (), bytes_transferred));

View File

@@ -136,19 +136,19 @@ protected:
return stream ().write_some (buffers, ec);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
return stream ().async_read_some (buffers, m_strand.wrap (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), boost::asio::placeholders::error,
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)));
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
return stream ().async_write_some (buffers, m_strand.wrap (boost::bind (
BOOST_ASIO_MOVE_CAST(TransferCall)(handler), boost::asio::placeholders::error,
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)));
}
@@ -160,34 +160,7 @@ protected:
/** Determine if the caller needs to call a handshaking function. */
bool needs_handshake ()
{
#if 1
return m_needs_handshake;
#else
if (is_server ())
{
// If the PROXY flag is on, we need that first
if (m_flags.set (Flag::proxy))
return true;
if (m_flags.any_set (Flag::ssl | Flag::ssl_required))
return true;
return false;
}
else if (is_client ())
{
// Client sends PROXY on the initial connect
// before We even get to this function.
if (m_flags.set (Flag::ssl))
return true;
return false;
}
bassert (is_peer ());
return false;
#endif
}
error_code handshake (Socket::handshake_type type, error_code& ec)
@@ -197,15 +170,25 @@ protected:
return ec;
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
bassert (m_context.isNull ());
error_code ec;
if (init_handshake (type, ec))
return stream ().async_handshake (type,
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
return get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler), ec));
{
// The original handler has already been wrapped for us
// so set the context and indicate the beginning of the
// composed operation.
//
//handler.beginComposed ();
//m_context = handler.getContext ();
return stream ().async_handshake (type, handler);
}
return get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler), ec));
}
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
@@ -217,15 +200,15 @@ protected:
return ec;
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(TransferCall, void (error_code, std::size_t))
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_handshake (handshake_type type, ConstBuffers const& buffers,
BOOST_ASIO_MOVE_ARG(TransferCall) handler)
BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
error_code ec;
if (init_handshake (type, ec))
return stream ().async_handshake (type, buffers,
BOOST_ASIO_MOVE_CAST(TransferCall)(handler));
return get_io_service ().post (CompletionCall (handler, ec, 0));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
return get_io_service ().post (HandlerCall (handler, ec, 0));
}
#endif
@@ -240,23 +223,23 @@ protected:
return handshake_error (ec);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(ErrorCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(ErrorCall) handler)
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
{
error_code ec;
if (m_needs_shutdown)
{
if (m_needs_shutdown_stream)
return stream ().async_shutdown (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler));
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
}
else
{
ec = handshake_error ();
}
return get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(handler),
return get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
ec));
}
@@ -568,14 +551,14 @@ protected:
}
void on_async_detect (LogicType& logic, error_code const& ec,
ConstBuffers const& buffers, ErrorCall const& origHandler)
ConstBuffers const& buffers, HandlerCall const& origHandler)
{
m_owner->on_async_detect_proxy (logic, ec, buffers, origHandler);
}
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
void on_async_detect (LogicType& logic, error_code const& ec,
ConstBuffers const& buffers, TransferCall const& origHandler)
ConstBuffers const& buffers, HandlerCall const& origHandler)
{
m_owner->on_async_detect_proxy (logic, ec, buffers, origHandler);
}
@@ -620,7 +603,7 @@ protected:
// origHandler cannot be a reference since it gets move-copied
void on_async_detect_proxy (HandshakeDetectLogicPROXY& logic,
error_code ec, ConstBuffers const& buffers, ErrorCall origHandler)
error_code ec, ConstBuffers const& buffers, HandlerCall origHandler)
{
if (! ec)
{
@@ -646,14 +629,14 @@ protected:
}
}
get_io_service ().post (CompletionCall (
BOOST_ASIO_MOVE_CAST(ErrorCall)(origHandler), ec));
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(origHandler), ec));
}
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
// origHandler cannot be a reference since it gets move-copied
void on_async_detect_proxy (HandshakeDetectLogicPROXY& logic,
error_code const& ec, ConstBuffers const& buffers, TransferCall origHandler)
error_code const& ec, ConstBuffers const& buffers, HandlerCall origHandler)
{
std::size_t bytes_transferred = 0;
@@ -699,7 +682,7 @@ protected:
// origHandler cannot be a reference since it gets move-copied
void on_async_detect_ssl (HandshakeDetectLogicSSL3& logic,
error_code const& ec, ConstBuffers const& buffers, ErrorCall origHandler)
error_code const& ec, ConstBuffers const& buffers, HandlerCall origHandler)
{
if (! ec)
{
@@ -718,14 +701,14 @@ protected:
}
// Is this a continuation?
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (HandlerCall::Post (),
origHandler, ec));
}
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
// origHandler cannot be a reference since it gets move-copied
void on_async_detect_ssl (HandshakeDetectLogicSSL3& logic,
error_code const& ec, ConstBuffers const& buffers, TransferCall origHandler)
error_code const& ec, ConstBuffers const& buffers, HandlerCall origHandler)
{
std::size_t bytes_transferred = 0;
@@ -748,7 +731,7 @@ protected:
}
// Is this a continuation?
get_io_service ().post (CompletionCall (
get_io_service ().post (HandlerCall (
origHandler, ec, bytes_transferred));
}
#endif
@@ -775,14 +758,14 @@ protected:
}
void on_async_detect (LogicType& logic, error_code const& ec,
ConstBuffers const& buffers, ErrorCall const& origHandler)
ConstBuffers const& buffers, HandlerCall const& origHandler)
{
m_owner->on_async_detect_ssl (logic, ec, buffers, origHandler);
}
#if BEAST_ASIO_HAS_BUFFEREDHANDSHAKE
void on_async_detect (LogicType& logic, error_code const& ec,
ConstBuffers const& buffers, TransferCall const& origHandler)
ConstBuffers const& buffers, HandlerCall const& origHandler)
{
m_owner->on_async_detect_ssl (logic, ec, buffers, origHandler);
}
@@ -821,6 +804,7 @@ private:
StreamSocket m_next_layer;
ScopedPointer <Socket> m_stream;
boost::asio::io_service::strand m_strand;
HandlerCall::Context m_context;
};
#endif