10 #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP 11 #define BOOST_BEAST_WEBSOCKET_DETAIL_PAUSATION_HPP 14 #include <boost/asio/coroutine.hpp> 15 #include <boost/assert.hpp> 35 base(base &&) =
delete;
36 base(base
const&) =
delete;
37 virtual ~base() =
default;
38 virtual void operator()() = 0;
46 holder(holder&&) =
default;
51 : f(std::forward<U>(u))
66 struct exemplar : boost::asio::coroutine
91 using boost::asio::asio_handler_deallocate;
94 Op op(std::move(*op_));
96 asio_handler_deallocate(op_,
97 sizeof(*op_), std::addressof(op.handler()));
101 saved_op(saved_op&& other)
118 using boost::asio::asio_handler_allocate;
119 op_ =
new(asio_handler_allocate(
sizeof(Op),
120 std::addressof(op.handler()))) Op{
128 Op op{std::move(*op_)};
129 using boost::asio::asio_handler_deallocate;
130 asio_handler_deallocate(op_,
131 sizeof(*op_), std::addressof(op_->handler()));
137 using buf_type =
char[
sizeof(holder<exemplar>)];
139 base* base_ =
nullptr;
140 alignas(holder<exemplar>) buf_type buf_;
155 BOOST_ASSERT(! other.base_);
161 BOOST_ASSERT(! base_);
162 BOOST_ASSERT(! other.base_);
175 operator bool()
const 177 return base_ !=
nullptr;
185 auto const basep = base_;
198 using type = holder<typename std::decay<F>::type>;
199 static_assert(
sizeof(buf_type) >=
sizeof(type),
201 BOOST_ASSERT(! base_);
202 base_ = ::new(buf_) type{std::forward<F>(f)};
209 emplace(saved_op<F>{std::move(f)});
~pausation()
Definition: pausation.hpp:147
void save(F &&f)
Definition: pausation.hpp:207
bool maybe_invoke()
Definition: pausation.hpp:181
Definition: async_result.hpp:20
Definition: handler_ptr.hpp:53
pausation & operator=(pausation &&other)
Definition: pausation.hpp:159
pausation & operator=(pausation const &)=delete
Definition: pausation.hpp:30
Definition: pausation.hpp:68
void emplace(F &&f)
Definition: pausation.hpp:196
pausation(pausation &&other)
Definition: pausation.hpp:153
Definition: pausation.hpp:73