Rename to websocket::detail::pausation

Fix #324
This commit is contained in:
Vinnie Falco
2017-04-27 17:29:25 -07:00
parent 4b02fe989f
commit 512ab5ba7d
4 changed files with 31 additions and 28 deletions

View File

@@ -6,6 +6,7 @@ WebSocket:
* Add is_upgrade() free function
* Document websocket::stream thread safety
* Rename to websocket::detail::pausation
API Changes:

View File

@@ -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 <beast/core/handler_ptr.hpp>
#include <boost/assert.hpp>
@@ -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<exemplar>) 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<class F>
void
invokable::emplace(F&& f)
pausation::emplace(F&& f)
{
static_assert(sizeof(buf_type) >= sizeof(holder<F>),
"buffer too small");

View File

@@ -12,8 +12,8 @@
#include <beast/websocket/option.hpp>
#include <beast/websocket/rfc6455.hpp>
#include <beast/websocket/detail/frame.hpp>
#include <beast/websocket/detail/invokable.hpp>
#include <beast/websocket/detail/mask.hpp>
#include <beast/websocket/detail/pausation.hpp>
#include <beast/websocket/detail/pmd_extension.hpp>
#include <beast/websocket/detail/utf8_checker.hpp>
#include <beast/http/message.hpp>
@@ -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

View File

@@ -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<socket_type> 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<socket_type> 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<socket_type> 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<socket_type> 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<socket_type> 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);
}