Tidy up argument types for all wrappers and call sites

This commit is contained in:
Vinnie Falco
2013-08-18 03:07:12 -07:00
parent 2d04fc4641
commit d571788172
7 changed files with 80 additions and 112 deletions

View File

@@ -252,7 +252,7 @@ bool HandlerCall::isFinal () const noexcept
return m_call->getContext () == m_call.get ();
}
HandlerCall& HandlerCall::beginComposed () noexcept
HandlerCall const& HandlerCall::beginComposed () const noexcept
{
// If this goes off it means that your handler is
// already sharing a context with another handler!
@@ -263,7 +263,7 @@ HandlerCall& HandlerCall::beginComposed () noexcept
return *this;
}
HandlerCall& HandlerCall::endComposed () noexcept
HandlerCall const& HandlerCall::endComposed () const noexcept
{
// If this goes off it means that your handler is
// already sharing a context with another handler!

View File

@@ -384,7 +384,7 @@ public:
@see isComposed, endComposed
*/
HandlerCall& beginComposed () noexcept;
HandlerCall const& beginComposed () const noexcept;
/** Indicate the end of a composed operation.
@@ -393,7 +393,7 @@ public:
own callback, using the original handler's context. To optimize the
strategy for calling completion handlers, call beginComposed.
*/
HandlerCall& endComposed () noexcept;
HandlerCall const& endComposed () const noexcept;
/** Invoke the wrapped handler.

View File

@@ -207,7 +207,7 @@ public:
// Get the execution context from the original handler
// and signal the beginning of our composed operation.
//
m_origHandler.beginComposed ();
//m_origHandler.beginComposed ();
m_context = m_origHandler.getContext ();
bassert (m_context.isNotNull ());
@@ -246,7 +246,7 @@ public:
// The composed operation has completed and
// the original handler will eventually get called.
//
m_origHandler.endComposed ();
//m_origHandler.endComposed ();
m_callback->on_async_detect (m_logic.get (), ec,
ConstBuffers (m_buffer.data ()), m_origHandler);
return;
@@ -273,7 +273,7 @@ public:
// Error condition
m_origHandler.endComposed ();
//m_origHandler.endComposed ();
m_callback->on_async_detect (m_logic.get (), ec,
ConstBuffers (m_buffer.data ()), m_origHandler);
}

View File

@@ -168,14 +168,13 @@ public:
BEAST_ASIO_INITFN_RESULT_TYPE(AcceptHandler, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
{
return async_accept (peer,
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Accept (),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler))));
return async_accept (peer, HandlerCall (HandlerCall::Accept (),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler)));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
async_accept (Socket& peer, HandlerCall const& handler);
//--------------------------------------------------------------------------
//
@@ -210,13 +209,13 @@ public:
async_read_some (MutableBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
return async_read_some (MutableBuffers (buffers),
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))));
HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)));
}
virtual
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);
async_read_some (MutableBuffers const& buffers, HandlerCall const& handler);
// AsyncWriteStream
// http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/AsyncWriteStream.html
@@ -225,13 +224,13 @@ public:
async_write_some (ConstBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
return async_write_some (ConstBuffers (buffers),
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))));
HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
}
virtual
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);
async_write_some (ConstBuffers const& buffers, HandlerCall const& handler);
//--------------------------------------------------------------------------
//
@@ -274,14 +273,13 @@ public:
BEAST_ASIO_INITFN_RESULT_TYPE(HandshakeHandler, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler)
{
return async_handshake (type,
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Error (),
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler))));
return async_handshake (type, HandlerCall (HandlerCall::Error (),
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler)));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
async_handshake (handshake_type type, HandlerCall const& handler);
//--------------------------------------------------------------------------
@@ -318,14 +316,13 @@ public:
BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler)
{
return async_handshake (type, ConstBuffers (buffers),
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)(handler))));
HandlerCall (HandlerCall::Transfer (),
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)(handler)));
}
virtual
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);
async_handshake (handshake_type type, ConstBuffers const& buffers, HandlerCall const& handler);
#endif
//--------------------------------------------------------------------------
@@ -347,14 +344,13 @@ public:
template <class ShutdownHandler>
void async_shutdown (BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler)
{
return async_shutdown (
BOOST_ASIO_MOVE_CAST(HandlerCall)(HandlerCall (HandlerCall::Error (),
BOOST_ASIO_MOVE_CAST(ShutdownHandler)(handler))));
return async_shutdown (HandlerCall (HandlerCall::Error (),
BOOST_ASIO_MOVE_CAST(ShutdownHandler)(handler)));
}
virtual
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler);
async_shutdown (HandlerCall const& handler);
};
#endif

View File

@@ -364,45 +364,39 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
async_accept (Socket& peer, HandlerCall const& handler)
{
using namespace SocketWrapperMemberChecks;
typedef typename native_socket <this_layer_type>::socket_type socket_type;
return async_accept (peer, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
return async_accept (peer, handler,
EnableIf <has_async_accept <this_layer_type,
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(HandlerCall, void (error_code))
async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_accept (Socket& peer, HandlerCall const& handler,
boost::true_type)
{
using namespace SocketWrapperMemberChecks;
return m_object.async_accept (
native_socket <this_layer_type> (peer).get (),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
native_socket <this_layer_type> (peer).get (), handler);
}
template <typename AcceptHandler>
BEAST_ASIO_INITFN_RESULT_TYPE(AcceptHandler, void (error_code))
async_accept (Socket&, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_accept (Socket&, HandlerCall const& handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
AcceptHandler, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
// init.handler is copied
HandlerCall, void (error_code)> init(handler);
get_io_service ().post (HandlerCall (HandlerCall::Post (),
AcceptHandler (init.handler), pure_virtual_error ()));
init.handler, pure_virtual_error ()));
return init.result.get();
#else
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler),
pure_virtual_error ()));
handler, pure_virtual_error ()));
#endif
}
@@ -472,33 +466,27 @@ public:
(MutableBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
}
template <typename MutableBufferSequence, typename ReadHandler>
BEAST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void (error_code, std::size_t))
async_read_some (MutableBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const& buffers, HandlerCall const& handler,
boost::true_type)
{
return m_object.async_read_some (buffers,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return m_object.async_read_some (buffers, handler);
}
template <typename MutableBufferSequence, typename ReadHandler>
BEAST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void (error_code, std::size_t))
async_read_some (MutableBufferSequence const&, BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
async_read_some (MutableBuffers const&, HandlerCall const& handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
ReadHandler, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
// init.handler is copied
HandlerCall, void (error_code, std::size_t)> init(handler);
get_io_service ().post (HandlerCall (HandlerCall::Post (),
ReadHandler (init.handler), pure_virtual_error (), 0));
init.handler, pure_virtual_error (), 0));
return init.result.get();
#else
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler),
pure_virtual_error (), 0));
handler, pure_virtual_error (), 0));
#endif
}
@@ -506,40 +494,36 @@ public:
//--------------------------------------------------------------------------
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)
async_write_some (ConstBuffers const& buffers, HandlerCall const& handler)
{
using namespace SocketWrapperMemberChecks;
return async_write_some (buffers, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
return async_write_some (buffers, handler,
EnableIf <has_async_write_some <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code, std::size_t))
(ConstBuffers const&, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
(ConstBuffers const&, HandlerCall const&)>::value> ());
}
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,
async_write_some (ConstBuffers const& buffers, HandlerCall const& handler,
boost::true_type)
{
return m_object.async_write_some (buffers,
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
return m_object.async_write_some (buffers, 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,
async_write_some (ConstBuffers const&, HandlerCall const& handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
HandlerCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
HandlerCall, void (error_code, std::size_t)> init(handler);
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error (), 0));
init.handler, pure_virtual_error (), 0));
return init.result.get();
#else
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error (), 0));
handler, pure_virtual_error (), 0));
#endif
}
@@ -585,39 +569,35 @@ public:
//--------------------------------------------------------------------------
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
async_handshake (handshake_type type, HandlerCall const& handler)
{
using namespace SocketWrapperMemberChecks;
return async_handshake (type, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
return async_handshake (type, handler,
EnableIf <has_async_handshake <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
(handshake_type, BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
(handshake_type, HandlerCall const& handler)>::value> ());
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
async_handshake (handshake_type type, HandlerCall const& handler,
boost::true_type)
{
return m_object.async_handshake (type,
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
return m_object.async_handshake (type, handler);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
async_handshake (handshake_type, HandlerCall const& handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
HandlerCall, void (error_code)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
HandlerCall, void (error_code)> init(handler);
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error ()));
init.handler, pure_virtual_error ()));
return init.result.get();
#else
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error ()));
handler, pure_virtual_error ()));
#endif
}
@@ -649,40 +629,36 @@ public:
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)
HandlerCall const& handler)
{
using namespace SocketWrapperMemberChecks;
return async_handshake (type, buffers, BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
return async_handshake (type, buffers, handler,
EnableIf <has_async_handshake <this_layer_type,
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(HandlerCall, void (error_code, std::size_t))
async_handshake (handshake_type type, ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
async_handshake (handshake_type type, ConstBuffers const& buffers, HandlerCall const& handler,
boost::true_type)
{
return m_object.async_handshake (type, buffers,
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
return m_object.async_handshake (type, buffers, 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,
async_handshake (handshake_type, ConstBuffers const&, HandlerCall const& handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
HandlerCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
HandlerCall, void (error_code, std::size_t)> init(handler);
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error (), 0));
init.handler, pure_virtual_error (), 0));
return init.result.get();
#else
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error (), 0));
handler, pure_virtual_error (), 0));
#endif
}
@@ -713,40 +689,36 @@ public:
//--------------------------------------------------------------------------
void async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler)
void async_shutdown (HandlerCall const& handler)
{
using namespace SocketWrapperMemberChecks;
return async_shutdown (BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
return async_shutdown (handler,
EnableIf <has_async_shutdown <this_layer_type,
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
(BOOST_ASIO_MOVE_ARG(HandlerCall))>::value> ());
(HandlerCall const& handler)>::value> ());
}
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(HandlerCall)(handler));
return m_object.async_shutdown (handler);
}
BEAST_ASIO_INITFN_RESULT_TYPE_MEMBER(HandlerCall, void (error_code))
async_shutdown (BOOST_ASIO_MOVE_ARG(HandlerCall) handler,
async_shutdown (HandlerCall const& handler,
boost::false_type)
{
#if BEAST_ASIO_HAS_FUTURE_RETURNS
boost::asio::detail::async_result_init<
HandlerCall, void (error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler));
// init.handler is copied
HandlerCall, void (error_code, std::size_t)> init(handler);
get_io_service ().post (HandlerCall (HandlerCall::Post (),
HandlerCall (init.handler), pure_virtual_error ()));
init.handler, pure_virtual_error ()));
return init.result.get();
#else
get_io_service ().post (HandlerCall (HandlerCall::Post (),
BOOST_ASIO_MOVE_CAST(HandlerCall)(handler),
pure_virtual_error ()));
handler, pure_virtual_error ()));
#endif
}

View File

@@ -226,8 +226,8 @@ public:
testProxyFlags <Protocol> (MultiSocket::Flag::proxy, MultiSocket::Flag::proxy);
testProxyFlags <Protocol> (MultiSocket::Flag::proxy | MultiSocket::Flag::ssl, MultiSocket::Flag::proxy | MultiSocket::Flag::ssl_required);
// testProxyFlags <Protocol> (MultiSocket::Flag::proxy, MultiSocket::Flag::proxy | MultiSocket::Flag::ssl);
// testProxyFlags <Protocol> (MultiSocket::Flag::proxy | MultiSocket::Flag::ssl, MultiSocket::Flag::proxy | MultiSocket::Flag::ssl);
testProxyFlags <Protocol> (MultiSocket::Flag::proxy, MultiSocket::Flag::proxy | MultiSocket::Flag::ssl);
testProxyFlags <Protocol> (MultiSocket::Flag::proxy | MultiSocket::Flag::ssl, MultiSocket::Flag::proxy | MultiSocket::Flag::ssl);
}
void runTest ()

View File

@@ -183,7 +183,7 @@ protected:
// composed operation.
//
//handler.beginComposed ();
//m_context = handler.getContext ();
m_context = handler.getContext ();
return stream ().async_handshake (type, handler);
}