diff --git a/Subtrees/beast/modules/beast_asio/basics/beast_CompletionCall.h b/Subtrees/beast/modules/beast_asio/basics/beast_CompletionCall.h index 09a4dfa16..444794905 100644 --- a/Subtrees/beast/modules/beast_asio/basics/beast_CompletionCall.h +++ b/Subtrees/beast/modules/beast_asio/basics/beast_CompletionCall.h @@ -30,9 +30,31 @@ class CompletionCall public: typedef void result_type; - template + // Construction from Handler with zero arguments + // + template CompletionCall (BOOST_ASIO_MOVE_ARG(Handler) handler) - : m_call (new CallType (BOOST_ASIO_MOVE_CAST(Handler)(handler))) + : m_call (new CallType0 (BOOST_ASIO_MOVE_CAST(Handler)(handler))) + { + } + + // Creates a CompletionHandler with one parameter bound to Handler + // This can convert an ErrorCall to a CompletionCall, suitable + // for calling asio::io_service::post() + // + template + CompletionCall (BOOST_ASIO_MOVE_ARG(Handler) handler, P1 p1) + : m_call (new CallType1 (BOOST_ASIO_MOVE_CAST(Handler)(handler), p1)) + { + } + + // Creates a CompletionHandler with two parameters bound to Handler + // This can convert a TransferCall to a CompletionCall, suitable + // for calling asio::io_service::post() + // + template + CompletionCall (BOOST_ASIO_MOVE_ARG(Handler) handler, P1 p1, P2 p2) + : m_call (new CallType2 (BOOST_ASIO_MOVE_CAST(Handler)(handler), p1, p2)) { } @@ -53,9 +75,9 @@ private: }; template - struct CallType : Call + struct CallType0 : Call { - CallType (BOOST_ASIO_MOVE_ARG(Handler) handler) + CallType0 (BOOST_ASIO_MOVE_ARG(Handler) handler) : m_handler (handler) { } @@ -68,6 +90,44 @@ private: Handler m_handler; }; + template + struct CallType1 : Call + { + CallType1 (BOOST_ASIO_MOVE_ARG(Handler) handler, P1 p1) + : m_handler (handler) + , m_p1 (p1) + { + } + + void operator() () + { + m_handler (m_p1); + } + + Handler m_handler; + P1 m_p1; + }; + + template + struct CallType2 : Call + { + CallType2 (BOOST_ASIO_MOVE_ARG(Handler) handler, P1 p1, P2 p2) + : m_handler (handler) + , m_p1 (p1) + , m_p2 (p2) + { + } + + void operator() () + { + m_handler (m_p1, m_p2); + } + + Handler m_handler; + P1 m_p1; + P2 m_p2; + }; + private: SharedObjectPtr m_call; };