| 43 | } |
| 44 | |
| 45 | bool cluster::stop_timer(timer t) { |
| 46 | /* |
| 47 | * Because iterating a priority queue is at best O(log n) we don't actually walk the queue |
| 48 | * looking for the timer to remove. Instead, we just insert the timer handle into a std::set |
| 49 | * to inform the tick_timers() function later if it sees a handle in this set, it is to |
| 50 | * have its on_stop() called and it is not to be rescheduled. |
| 51 | */ |
| 52 | std::lock_guard<std::mutex> l(timer_guard); |
| 53 | deleted_timers.emplace(t); |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | void cluster::tick_timers() { |
| 58 | time_t now = time(nullptr); |