diff --git a/CHANGELOG.md b/CHANGELOG.md index dcb08701..3f1daf5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ WebSocket: * Add is_upgrade() free function * Document websocket::stream thread safety +* Rename to websocket::detail::pausation API Changes: diff --git a/include/beast/websocket/detail/invokable.hpp b/include/beast/websocket/detail/pausation.hpp similarity index 83% rename from include/beast/websocket/detail/invokable.hpp rename to include/beast/websocket/detail/pausation.hpp index 80701083..42893ca2 100644 --- a/include/beast/websocket/detail/invokable.hpp +++ b/include/beast/websocket/detail/pausation.hpp @@ -5,8 +5,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP -#define BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP +#ifndef BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP +#define BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP #include #include @@ -19,9 +19,11 @@ namespace beast { namespace websocket { namespace detail { -// "Parks" a composed operation, to invoke later +// A container that holds a suspended, asynchronous composed +// operation. The contained object may be invoked later to +// resume the operation, or the container may be destroyed. // -class invokable +class pausation { struct base { @@ -58,7 +60,7 @@ class invokable F f_(std::move(f)); this->~holder(); // invocation of f_() can - // assign a new invokable. + // assign a new object to *this. f_(); } }; @@ -86,15 +88,15 @@ class invokable alignas(holder) buf_type buf_; public: - ~invokable() + ~pausation() { if(base_) base_->~base(); } - invokable() = default; + pausation() = default; - invokable(invokable&& other) + pausation(pausation&& other) { if(other.base_) { @@ -105,10 +107,10 @@ public: } } - invokable& - operator=(invokable&& other) + pausation& + operator=(pausation&& other) { - // Engaged invokables must be invoked before + // Engaged pausations must be invoked before // assignment otherwise the io_service // completion invariants are broken. BOOST_ASSERT(! base_); @@ -143,7 +145,7 @@ public: template void -invokable::emplace(F&& f) +pausation::emplace(F&& f) { static_assert(sizeof(buf_type) >= sizeof(holder), "buffer too small"); diff --git a/include/beast/websocket/detail/stream_base.hpp b/include/beast/websocket/detail/stream_base.hpp index 66ede62e..1fa45d55 100644 --- a/include/beast/websocket/detail/stream_base.hpp +++ b/include/beast/websocket/detail/stream_base.hpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -64,9 +64,9 @@ protected: op* wr_block_; // op currenly writing ping_data* ping_data_; // where to put the payload - invokable rd_op_; // read parking - invokable wr_op_; // write parking - invokable ping_op_; // ping parking + pausation rd_op_; // parked read op + pausation wr_op_; // parked write op + pausation ping_op_; // parked ping op close_reason cr_; // set from received close frame // State information for the message being received diff --git a/test/websocket/stream.cpp b/test/websocket/stream.cpp index c3072ea7..f9fa9037 100644 --- a/test/websocket/stream.cpp +++ b/test/websocket/stream.cpp @@ -1259,7 +1259,7 @@ public: } #if 0 - void testInvokable1(endpoint_type const& ep) + void testPausation1(endpoint_type const& ep) { boost::asio::io_service ios; stream ws(ios); @@ -1293,7 +1293,7 @@ public: while(! ws.wr_block_) ios.run_one(); // Write a text message, leaving - // the write_op suspended as invokable. + // the write_op suspended as pausation. ws.async_write(sbuf("Hello"), [&](error_code ec) { @@ -1326,7 +1326,7 @@ public: } #endif - void testInvokable2(endpoint_type const& ep) + void testPausation2(endpoint_type const& ep) { boost::asio::io_service ios; stream ws(ios); @@ -1363,7 +1363,7 @@ public: while(! ws.wr_block_) ios.run_one(); // Write a text message, leaving - // the write_op suspended as invokable. + // the write_op suspended as a pausation. ws.async_write(sbuf("Hello"), [&](error_code ec) { @@ -1395,7 +1395,7 @@ public: ios.run(); } - void testInvokable3(endpoint_type const& ep) + void testPausation3(endpoint_type const& ep) { boost::asio::io_service ios; stream ws(ios); @@ -1461,7 +1461,7 @@ public: ios.run(); } - void testInvokable4(endpoint_type const& ep) + void testPausation4(endpoint_type const& ep) { boost::asio::io_service ios; stream ws(ios); @@ -1505,7 +1505,7 @@ public: } #if 0 - void testInvokable5(endpoint_type const& ep) + void testPausation5(endpoint_type const& ep) { boost::asio::io_service ios; stream ws(ios); @@ -1870,11 +1870,11 @@ public: server.open(any, ec); BEAST_EXPECTS(! ec, ec.message()); auto const ep = server.local_endpoint(); - //testInvokable1(ep); - testInvokable2(ep); - testInvokable3(ep); - testInvokable4(ep); - //testInvokable5(ep); + //testPausation1(ep); + testPausation2(ep); + testPausation3(ep); + testPausation4(ep); + //testPausation5(ep); testWriteFrames(ep); testAsyncWriteFrame(ep); }