summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/detail/timer_queue.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/detail/timer_queue.hpp')
-rw-r--r--3rdparty/asio/include/asio/detail/timer_queue.hpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/3rdparty/asio/include/asio/detail/timer_queue.hpp b/3rdparty/asio/include/asio/detail/timer_queue.hpp
index 1575e03af7b..843f3614da0 100644
--- a/3rdparty/asio/include/asio/detail/timer_queue.hpp
+++ b/3rdparty/asio/include/asio/detail/timer_queue.hpp
@@ -2,7 +2,7 @@
// detail/timer_queue.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -150,7 +150,12 @@ public:
while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0].time_))
{
per_timer_data* timer = heap_[0].timer_;
- ops.push(timer->op_queue_);
+ while (wait_op* op = timer->op_queue_.front())
+ {
+ timer->op_queue_.pop();
+ op->ec_ = asio::error_code();
+ ops.push(op);
+ }
remove_timer(*timer);
}
}
@@ -192,6 +197,30 @@ public:
return num_cancelled;
}
+ // Cancel and dequeue a specific operation for the given timer.
+ void cancel_timer_by_key(per_timer_data* timer,
+ op_queue<operation>& ops, void* cancellation_key)
+ {
+ if (timer->prev_ != 0 || timer == timers_)
+ {
+ op_queue<wait_op> other_ops;
+ while (wait_op* op = timer->op_queue_.front())
+ {
+ timer->op_queue_.pop();
+ if (op->cancellation_key_ == cancellation_key)
+ {
+ op->ec_ = asio::error::operation_aborted;
+ ops.push(op);
+ }
+ else
+ other_ops.push(op);
+ }
+ timer->op_queue_.push(other_ops);
+ if (timer->op_queue_.empty())
+ remove_timer(*timer);
+ }
+ }
+
// Move operations from one timer to another, empty timer.
void move_timer(per_timer_data& target, per_timer_data& source)
{
@@ -266,11 +295,13 @@ private:
{
if (index == heap_.size() - 1)
{
+ timer.heap_index_ = (std::numeric_limits<std::size_t>::max)();
heap_.pop_back();
}
else
{
swap_heap(index, heap_.size() - 1);
+ timer.heap_index_ = (std::numeric_limits<std::size_t>::max)();
heap_.pop_back();
if (index > 0 && Time_Traits::less_than(
heap_[index].time_, heap_[(index - 1) / 2].time_))