Cancel and dequeue operations for the given timer.
| 173 | |
| 174 | // Cancel and dequeue operations for the given timer. |
| 175 | std::size_t cancel_timer(per_timer_data& timer, op_queue<operation>& ops, |
| 176 | std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)()) |
| 177 | { |
| 178 | std::size_t num_cancelled = 0; |
| 179 | if (timer.prev_ != 0 || &timer == timers_) |
| 180 | { |
| 181 | while (wait_op* op = (num_cancelled != max_cancelled) |
| 182 | ? timer.op_queue_.front() : 0) |
| 183 | { |
| 184 | op->ec_ = asio::error::operation_aborted; |
| 185 | timer.op_queue_.pop(); |
| 186 | ops.push(op); |
| 187 | ++num_cancelled; |
| 188 | } |
| 189 | if (timer.op_queue_.empty()) |
| 190 | remove_timer(timer); |
| 191 | } |
| 192 | return num_cancelled; |
| 193 | } |
| 194 | |
| 195 | // Move operations from one timer to another, empty timer. |
| 196 | void move_timer(per_timer_data& target, per_timer_data& source) |