diff options
author | 2021-11-15 04:15:13 +1100 | |
---|---|---|
committer | 2021-11-15 04:15:13 +1100 | |
commit | 44ec6d2e0ee569202b75b73eea40972595866779 (patch) | |
tree | b286443c264704198789514e0594dc24b3ca9f96 /3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp | |
parent | 137f254b918f1f1ebee43dfbed86793b0dae73eb (diff) |
3rdparty: Updated ASIO to version 1.20.0.
The doc folder isn't included as it's pretty big.
This required include/asio/detail/win_iocp_socket_accept_op.hpp due to
mismatched order in the member declarations and initialiser list for the
win_iocp_socket_accept_op class. I reversed the declaration order so it
matches win_iocp_socket_move_accept_op.
Diffstat (limited to '3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp')
-rw-r--r-- | 3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp b/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp index 86bf860cb9c..f441e322688 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp @@ -11,6 +11,7 @@ #include <queue> #include <thread> #include <vector> +#include <cctype> using asio::execution_context; using asio::executor_binder; @@ -19,9 +20,10 @@ using asio::post; using asio::system_executor; using asio::use_future; using asio::use_service; +namespace execution = asio::execution; // An executor that launches a new thread for each function submitted to it. -// This class satisfies the Executor requirements. +// This class satisfies the executor requirements. class thread_executor { private: @@ -54,40 +56,28 @@ private: }; public: - execution_context& context() const noexcept + execution_context& query(execution::context_t) const { - return system_executor().context(); + return asio::query(system_executor(), execution::context); } - void on_work_started() const noexcept + execution::blocking_t query(execution::blocking_t) const { - // This executor doesn't count work. + return execution::blocking.never; } - void on_work_finished() const noexcept + thread_executor require(execution::blocking_t::never_t) const { - // This executor doesn't count work. + return *this; } - template <class Func, class Alloc> - void dispatch(Func&& f, const Alloc& a) const + template <class Func> + void execute(Func f) const { - post(std::forward<Func>(f), a); - } - - template <class Func, class Alloc> - void post(Func f, const Alloc&) const - { - thread_bag& bag = use_service<thread_bag>(context()); + thread_bag& bag = use_service<thread_bag>(query(execution::context)); bag.add_thread(std::thread(std::move(f))); } - template <class Func, class Alloc> - void defer(Func&& f, const Alloc& a) const - { - post(std::forward<Func>(f), a); - } - friend bool operator==(const thread_executor&, const thread_executor&) noexcept { @@ -291,7 +281,7 @@ void writer(queue_back<std::string> in) int main() { - thread_pool pool; + thread_pool pool(1); auto f = pipeline(reader, filter, bind_executor(pool, upper), writer); f.wait(); |