| 175 | } |
| 176 | |
| 177 | void timer_queue::add_timer(std::unique_lock<std::mutex>& lock, timer_ptr new_timer) { |
| 178 | assert(lock.owns_lock()); |
| 179 | |
| 180 | if (m_abort) { |
| 181 | throw errors::runtime_shutdown(details::consts::k_timer_queue_shutdown_err_msg); |
| 182 | } |
| 183 | |
| 184 | auto old_thread = ensure_worker_thread(lock); |
| 185 | add_internal_timer(lock, new_timer); |
| 186 | |
| 187 | if (old_thread.joinable()) { |
| 188 | old_thread.join(); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | void timer_queue::work_loop() { |
| 193 | time_point next_deadline; |