mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 22:04:34 +02:00
@@ -140,8 +140,13 @@ async_echo(
|
|||||||
// The class template `async_op_base` holds the caller's completion
|
// The class template `async_op_base` holds the caller's completion
|
||||||
// handler for us, and provides all of the boilerplate for forwarding
|
// handler for us, and provides all of the boilerplate for forwarding
|
||||||
// the associated allocator and associated executor from the caller's
|
// the associated allocator and associated executor from the caller's
|
||||||
// handler to our operation. We declare this type alias to make the
|
// handler to our operation. It also maintains a `net::executor_work_guard`
|
||||||
// code easier to read.
|
// 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<
|
using base_type = beast::async_op_base<
|
||||||
handler_type, /*< The type of the completion handler obtained from the token >*/
|
handler_type, /*< The type of the completion handler obtained from the token >*/
|
||||||
|
@@ -188,7 +188,7 @@ class async_op_base
|
|||||||
"Executor requirements not met");
|
"Executor requirements not met");
|
||||||
|
|
||||||
Handler h_;
|
Handler h_;
|
||||||
net::executor_work_guard<Executor1> wg_;
|
net::executor_work_guard<Executor1> wg1_;
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
void
|
void
|
||||||
@@ -230,7 +230,7 @@ public:
|
|||||||
Handler_&& handler,
|
Handler_&& handler,
|
||||||
Executor1 const& ex1)
|
Executor1 const& ex1)
|
||||||
: h_(std::forward<Handler_>(handler))
|
: h_(std::forward<Handler_>(handler))
|
||||||
, wg_(ex1)
|
, wg1_(ex1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ public:
|
|||||||
: boost::empty_value<Allocator>(
|
: boost::empty_value<Allocator>(
|
||||||
boost::empty_init_t{}, alloc)
|
boost::empty_init_t{}, alloc)
|
||||||
, h_(std::forward<Handler_>(handler))
|
, h_(std::forward<Handler_>(handler))
|
||||||
, wg_(ex1)
|
, wg1_(ex1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -291,7 +291,7 @@ public:
|
|||||||
get_executor() const noexcept
|
get_executor() const noexcept
|
||||||
{
|
{
|
||||||
return net::get_associated_executor(
|
return net::get_associated_executor(
|
||||||
h_, wg_.get_executor());
|
h_, wg1_.get_executor());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the handler associated with this object
|
/// Returns the handler associated with this object
|
||||||
@@ -329,7 +329,7 @@ public:
|
|||||||
invoke(Args&&... args)
|
invoke(Args&&... args)
|
||||||
{
|
{
|
||||||
this->before_invoke_hook();
|
this->before_invoke_hook();
|
||||||
wg_.reset();
|
wg1_.reset();
|
||||||
h_(std::forward<Args>(args)...);
|
h_(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,13 +65,13 @@ class saved_handler::impl final : public base
|
|||||||
|
|
||||||
ebo_pair v_;
|
ebo_pair v_;
|
||||||
net::executor_work_guard<
|
net::executor_work_guard<
|
||||||
net::associated_executor_t<Handler>> wg_;
|
net::associated_executor_t<Handler>> wg2_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<class Handler_>
|
template<class Handler_>
|
||||||
impl(alloc_type const& a, Handler_&& h)
|
impl(alloc_type const& a, Handler_&& h)
|
||||||
: v_(a, std::forward<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