mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
@@ -140,8 +140,13 @@ async_echo(
|
||||
// The class template `async_op_base` holds the caller's completion
|
||||
// handler for us, and provides all of the boilerplate for forwarding
|
||||
// the associated allocator and associated executor from the caller's
|
||||
// handler to our operation. We declare this type alias to make the
|
||||
// code easier to read.
|
||||
// handler to our operation. It also maintains a `net::executor_work_guard`
|
||||
// for the executor associated with the stream. This work guard is
|
||||
// inexpensive, and prevents the execution context from running out
|
||||
// of work. It is usually necessary although rarely it can be skipped
|
||||
// depending on the operation (this echo example needs it because it
|
||||
// performs more than one asynchronous operation in a row).
|
||||
// We declare this type alias to make the code easier to read.
|
||||
|
||||
using base_type = beast::async_op_base<
|
||||
handler_type, /*< The type of the completion handler obtained from the token >*/
|
||||
|
@@ -188,7 +188,7 @@ class async_op_base
|
||||
"Executor requirements not met");
|
||||
|
||||
Handler h_;
|
||||
net::executor_work_guard<Executor1> wg_;
|
||||
net::executor_work_guard<Executor1> wg1_;
|
||||
|
||||
virtual
|
||||
void
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
Handler_&& handler,
|
||||
Executor1 const& ex1)
|
||||
: h_(std::forward<Handler_>(handler))
|
||||
, wg_(ex1)
|
||||
, wg1_(ex1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
: boost::empty_value<Allocator>(
|
||||
boost::empty_init_t{}, alloc)
|
||||
, h_(std::forward<Handler_>(handler))
|
||||
, wg_(ex1)
|
||||
, wg1_(ex1)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
get_executor() const noexcept
|
||||
{
|
||||
return net::get_associated_executor(
|
||||
h_, wg_.get_executor());
|
||||
h_, wg1_.get_executor());
|
||||
}
|
||||
|
||||
/// Returns the handler associated with this object
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
invoke(Args&&... args)
|
||||
{
|
||||
this->before_invoke_hook();
|
||||
wg_.reset();
|
||||
wg1_.reset();
|
||||
h_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@@ -65,13 +65,13 @@ class saved_handler::impl final : public base
|
||||
|
||||
ebo_pair v_;
|
||||
net::executor_work_guard<
|
||||
net::associated_executor_t<Handler>> wg_;
|
||||
net::associated_executor_t<Handler>> wg2_;
|
||||
|
||||
public:
|
||||
template<class Handler_>
|
||||
impl(alloc_type const& a, Handler_&& h)
|
||||
: v_(a, std::forward<Handler_>(h))
|
||||
, wg_(net::get_associated_executor(v_.h))
|
||||
, wg2_(net::get_associated_executor(v_.h))
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user