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/priority_scheduler.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/priority_scheduler.cpp')
-rw-r--r-- | 3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp b/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp index fb38fa2ce4b..d8ef79f3a51 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp @@ -8,6 +8,7 @@ using asio::dispatch; using asio::execution_context; +namespace execution = asio::execution; class priority_scheduler : public execution_context { @@ -21,47 +22,20 @@ public: { } - priority_scheduler& context() const noexcept + priority_scheduler& query(execution::context_t) const noexcept { return context_; } - void on_work_started() const noexcept + template <class Func> + void execute(Func f) const { - // This executor doesn't count work. Instead, the scheduler simply runs - // until explicitly stopped. - } - - void on_work_finished() const noexcept - { - // This executor doesn't count work. Instead, the scheduler simply runs - // until explicitly stopped. - } - - template <class Func, class Alloc> - void dispatch(Func&& f, const Alloc& a) const - { - post(std::forward<Func>(f), a); - } - - template <class Func, class Alloc> - void post(Func f, const Alloc& a) const - { - auto p(std::allocate_shared<item<Func>>( - typename std::allocator_traits< - Alloc>::template rebind_alloc<char>(a), - priority_, std::move(f))); + auto p(std::make_shared<item<Func>>(priority_, std::move(f))); std::lock_guard<std::mutex> lock(context_.mutex_); context_.queue_.push(p); context_.condition_.notify_one(); } - template <class Func, class Alloc> - void defer(Func&& f, const Alloc& a) const - { - post(std::forward<Func>(f), a); - } - friend bool operator==(const executor_type& a, const executor_type& b) noexcept { @@ -79,6 +53,12 @@ public: int priority_; }; + ~priority_scheduler() noexcept + { + shutdown(); + destroy(); + } + executor_type get_executor(int pri = 0) noexcept { return executor_type(*const_cast<priority_scheduler*>(this), pri); |