mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
@@ -6,6 +6,7 @@ WebSocket:
|
|||||||
|
|
||||||
* Add is_upgrade() free function
|
* Add is_upgrade() free function
|
||||||
* Document websocket::stream thread safety
|
* Document websocket::stream thread safety
|
||||||
|
* Rename to websocket::detail::pausation
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP
|
#ifndef BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP
|
||||||
#define BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP
|
#define BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP
|
||||||
|
|
||||||
#include <beast/core/handler_ptr.hpp>
|
#include <beast/core/handler_ptr.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@@ -19,9 +19,11 @@ namespace beast {
|
|||||||
namespace websocket {
|
namespace websocket {
|
||||||
namespace detail {
|
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
|
struct base
|
||||||
{
|
{
|
||||||
@@ -58,7 +60,7 @@ class invokable
|
|||||||
F f_(std::move(f));
|
F f_(std::move(f));
|
||||||
this->~holder();
|
this->~holder();
|
||||||
// invocation of f_() can
|
// invocation of f_() can
|
||||||
// assign a new invokable.
|
// assign a new object to *this.
|
||||||
f_();
|
f_();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -86,15 +88,15 @@ class invokable
|
|||||||
alignas(holder<exemplar>) buf_type buf_;
|
alignas(holder<exemplar>) buf_type buf_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~invokable()
|
~pausation()
|
||||||
{
|
{
|
||||||
if(base_)
|
if(base_)
|
||||||
base_->~base();
|
base_->~base();
|
||||||
}
|
}
|
||||||
|
|
||||||
invokable() = default;
|
pausation() = default;
|
||||||
|
|
||||||
invokable(invokable&& other)
|
pausation(pausation&& other)
|
||||||
{
|
{
|
||||||
if(other.base_)
|
if(other.base_)
|
||||||
{
|
{
|
||||||
@@ -105,10 +107,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
invokable&
|
pausation&
|
||||||
operator=(invokable&& other)
|
operator=(pausation&& other)
|
||||||
{
|
{
|
||||||
// Engaged invokables must be invoked before
|
// Engaged pausations must be invoked before
|
||||||
// assignment otherwise the io_service
|
// assignment otherwise the io_service
|
||||||
// completion invariants are broken.
|
// completion invariants are broken.
|
||||||
BOOST_ASSERT(! base_);
|
BOOST_ASSERT(! base_);
|
||||||
@@ -143,7 +145,7 @@ public:
|
|||||||
|
|
||||||
template<class F>
|
template<class F>
|
||||||
void
|
void
|
||||||
invokable::emplace(F&& f)
|
pausation::emplace(F&& f)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(buf_type) >= sizeof(holder<F>),
|
static_assert(sizeof(buf_type) >= sizeof(holder<F>),
|
||||||
"buffer too small");
|
"buffer too small");
|
@@ -12,8 +12,8 @@
|
|||||||
#include <beast/websocket/option.hpp>
|
#include <beast/websocket/option.hpp>
|
||||||
#include <beast/websocket/rfc6455.hpp>
|
#include <beast/websocket/rfc6455.hpp>
|
||||||
#include <beast/websocket/detail/frame.hpp>
|
#include <beast/websocket/detail/frame.hpp>
|
||||||
#include <beast/websocket/detail/invokable.hpp>
|
|
||||||
#include <beast/websocket/detail/mask.hpp>
|
#include <beast/websocket/detail/mask.hpp>
|
||||||
|
#include <beast/websocket/detail/pausation.hpp>
|
||||||
#include <beast/websocket/detail/pmd_extension.hpp>
|
#include <beast/websocket/detail/pmd_extension.hpp>
|
||||||
#include <beast/websocket/detail/utf8_checker.hpp>
|
#include <beast/websocket/detail/utf8_checker.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <beast/http/message.hpp>
|
||||||
@@ -64,9 +64,9 @@ protected:
|
|||||||
op* wr_block_; // op currenly writing
|
op* wr_block_; // op currenly writing
|
||||||
|
|
||||||
ping_data* ping_data_; // where to put the payload
|
ping_data* ping_data_; // where to put the payload
|
||||||
invokable rd_op_; // read parking
|
pausation rd_op_; // parked read op
|
||||||
invokable wr_op_; // write parking
|
pausation wr_op_; // parked write op
|
||||||
invokable ping_op_; // ping parking
|
pausation ping_op_; // parked ping op
|
||||||
close_reason cr_; // set from received close frame
|
close_reason cr_; // set from received close frame
|
||||||
|
|
||||||
// State information for the message being received
|
// State information for the message being received
|
||||||
|
@@ -1259,7 +1259,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void testInvokable1(endpoint_type const& ep)
|
void testPausation1(endpoint_type const& ep)
|
||||||
{
|
{
|
||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
stream<socket_type> ws(ios);
|
stream<socket_type> ws(ios);
|
||||||
@@ -1293,7 +1293,7 @@ public:
|
|||||||
while(! ws.wr_block_)
|
while(! ws.wr_block_)
|
||||||
ios.run_one();
|
ios.run_one();
|
||||||
// Write a text message, leaving
|
// Write a text message, leaving
|
||||||
// the write_op suspended as invokable.
|
// the write_op suspended as pausation.
|
||||||
ws.async_write(sbuf("Hello"),
|
ws.async_write(sbuf("Hello"),
|
||||||
[&](error_code ec)
|
[&](error_code ec)
|
||||||
{
|
{
|
||||||
@@ -1326,7 +1326,7 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void testInvokable2(endpoint_type const& ep)
|
void testPausation2(endpoint_type const& ep)
|
||||||
{
|
{
|
||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
stream<socket_type> ws(ios);
|
stream<socket_type> ws(ios);
|
||||||
@@ -1363,7 +1363,7 @@ public:
|
|||||||
while(! ws.wr_block_)
|
while(! ws.wr_block_)
|
||||||
ios.run_one();
|
ios.run_one();
|
||||||
// Write a text message, leaving
|
// Write a text message, leaving
|
||||||
// the write_op suspended as invokable.
|
// the write_op suspended as a pausation.
|
||||||
ws.async_write(sbuf("Hello"),
|
ws.async_write(sbuf("Hello"),
|
||||||
[&](error_code ec)
|
[&](error_code ec)
|
||||||
{
|
{
|
||||||
@@ -1395,7 +1395,7 @@ public:
|
|||||||
ios.run();
|
ios.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void testInvokable3(endpoint_type const& ep)
|
void testPausation3(endpoint_type const& ep)
|
||||||
{
|
{
|
||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
stream<socket_type> ws(ios);
|
stream<socket_type> ws(ios);
|
||||||
@@ -1461,7 +1461,7 @@ public:
|
|||||||
ios.run();
|
ios.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void testInvokable4(endpoint_type const& ep)
|
void testPausation4(endpoint_type const& ep)
|
||||||
{
|
{
|
||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
stream<socket_type> ws(ios);
|
stream<socket_type> ws(ios);
|
||||||
@@ -1505,7 +1505,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void testInvokable5(endpoint_type const& ep)
|
void testPausation5(endpoint_type const& ep)
|
||||||
{
|
{
|
||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
stream<socket_type> ws(ios);
|
stream<socket_type> ws(ios);
|
||||||
@@ -1870,11 +1870,11 @@ public:
|
|||||||
server.open(any, ec);
|
server.open(any, ec);
|
||||||
BEAST_EXPECTS(! ec, ec.message());
|
BEAST_EXPECTS(! ec, ec.message());
|
||||||
auto const ep = server.local_endpoint();
|
auto const ep = server.local_endpoint();
|
||||||
//testInvokable1(ep);
|
//testPausation1(ep);
|
||||||
testInvokable2(ep);
|
testPausation2(ep);
|
||||||
testInvokable3(ep);
|
testPausation3(ep);
|
||||||
testInvokable4(ep);
|
testPausation4(ep);
|
||||||
//testInvokable5(ep);
|
//testPausation5(ep);
|
||||||
testWriteFrames(ep);
|
testWriteFrames(ep);
|
||||||
testAsyncWriteFrame(ep);
|
testAsyncWriteFrame(ep);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user