mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
Replace detail/work_guard.hpp
with net::executor_work_guard
In newer versions of Asio, `executor_work_guard<>` can be used even when `ASIO_NO_TS_EXECUTORS` is defined.
This commit is contained in:
committed by
Mohammad Nejati
parent
78478557f6
commit
19c38c308a
@@ -44,7 +44,7 @@ struct ex1_type
|
||||
{
|
||||
|
||||
net::execution_context &
|
||||
query(net::execution::context_t c) const noexcept
|
||||
query(net::execution::context_t) const noexcept
|
||||
{ return *reinterpret_cast<net::execution_context *>(&ex1ctx); }
|
||||
|
||||
net::execution::blocking_t
|
||||
@@ -52,23 +52,23 @@ struct ex1_type
|
||||
{ return net::execution::blocking; };
|
||||
|
||||
net::execution::outstanding_work_t
|
||||
query(net::execution::outstanding_work_t w) const noexcept
|
||||
query(net::execution::outstanding_work_t) const noexcept
|
||||
{ return net::execution::outstanding_work; }
|
||||
|
||||
ex1_type
|
||||
require(net::execution::blocking_t::possibly_t b) const
|
||||
require(net::execution::blocking_t::possibly_t) const
|
||||
{ return *this; }
|
||||
|
||||
ex1_type
|
||||
require(net::execution::blocking_t::never_t b) const
|
||||
require(net::execution::blocking_t::never_t) const
|
||||
{ return *this; };
|
||||
|
||||
ex1_type
|
||||
prefer(net::execution::outstanding_work_t::untracked_t w) const
|
||||
prefer(net::execution::outstanding_work_t::untracked_t) const
|
||||
{ return *this; };
|
||||
|
||||
ex1_type
|
||||
prefer(net::execution::outstanding_work_t::tracked_t w) const
|
||||
prefer(net::execution::outstanding_work_t::tracked_t) const
|
||||
{ return *this; };
|
||||
|
||||
template<class F>
|
||||
|
@@ -69,6 +69,7 @@ public:
|
||||
template<class F>
|
||||
void execute(F&&) const {}
|
||||
simple_executor prefer(net::execution::outstanding_work_t::tracked_t) const { return *this; }
|
||||
simple_executor require(net::execution::blocking_t::never_t) const { return *this; };
|
||||
#else
|
||||
void* context() { return nullptr; }
|
||||
void on_work_started() {}
|
||||
|
@@ -41,9 +41,7 @@ protected:
|
||||
net::io_context ioc_;
|
||||
|
||||
private:
|
||||
beast::detail::select_work_guard_t<
|
||||
net::io_context::executor_type>
|
||||
work_;
|
||||
net::executor_work_guard<net::io_context::executor_type> work_;
|
||||
std::vector<std::thread> threads_;
|
||||
std::mutex m_;
|
||||
std::condition_variable cv_;
|
||||
@@ -56,8 +54,7 @@ public:
|
||||
|
||||
explicit
|
||||
enable_yield_to(std::size_t concurrency = 1)
|
||||
: work_(beast::detail::make_work_guard(
|
||||
ioc_.get_executor()))
|
||||
: work_(ioc_.get_executor())
|
||||
{
|
||||
threads_.reserve(concurrency);
|
||||
while(concurrency--)
|
||||
|
Reference in New Issue
Block a user