diff --git a/CHANGELOG.md b/CHANGELOG.md index cd90f994..37af2c2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 209: * Faster http::string_to_field * async_echo supports move-only handlers +* test::stream maintains a handler work guard -------------------------------------------------------------------------------- diff --git a/include/boost/beast/_experimental/test/impl/stream.hpp b/include/boost/beast/_experimental/test/impl/stream.hpp index c4e47107..c9190cb6 100644 --- a/include/boost/beast/_experimental/test/impl/stream.hpp +++ b/include/boost/beast/_experimental/test/impl/stream.hpp @@ -450,13 +450,16 @@ TeardownHandler&& handler) template class stream::read_op : public stream::read_op_base { + using ex1_type = net::io_context::executor_type; + using ex2_type = net::associated_executor_t; + class lambda { state& s_; Buffers b_; Handler h_; - net::executor_work_guard< - net::io_context::executor_type> work_; + net::executor_work_guard wg1_; + net::executor_work_guard wg2_; public: lambda(lambda&&) = default; @@ -467,7 +470,9 @@ class stream::read_op : public stream::read_op_base : s_(s) , b_(b) , h_(std::forward(h)) - , work_(s_.ioc.get_executor()) + , wg1_(s_.ioc.get_executor()) + , wg2_(net::get_associated_executor( + h_, s_.ioc.get_executor())) { } @@ -477,7 +482,8 @@ class stream::read_op : public stream::read_op_base net::post( s_.ioc.get_executor(), std::move(*this)); - work_.reset(); + wg1_.reset(); + wg2_.reset(); } void