| 190 | } |
| 191 | |
| 192 | void timer_queue::work_loop() { |
| 193 | time_point next_deadline; |
| 194 | details::timer_queue_internal internal_state; |
| 195 | |
| 196 | while (true) { |
| 197 | std::unique_lock<decltype(m_lock)> lock(m_lock); |
| 198 | if (internal_state.empty()) { |
| 199 | const auto res = m_condition.wait_for(lock, m_max_waiting_time, [this] { |
| 200 | return !m_request_queue.empty() || m_abort; |
| 201 | }); |
| 202 | |
| 203 | if (!res) { |
| 204 | m_idle = true; |
| 205 | lock.unlock(); |
| 206 | return; |
| 207 | } |
| 208 | |
| 209 | } else { |
| 210 | m_condition.wait_until(lock, next_deadline, [this] { |
| 211 | return !m_request_queue.empty() || m_abort; |
| 212 | }); |
| 213 | } |
| 214 | |
| 215 | if (m_abort) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | auto request_queue = std::move(m_request_queue); |
| 220 | lock.unlock(); |
| 221 | |
| 222 | next_deadline = internal_state.process_timers(request_queue); |
| 223 | const auto now = clock_type::now(); |
| 224 | if (next_deadline <= now) { |
| 225 | continue; |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | bool timer_queue::shutdown_requested() const noexcept { |
| 231 | return m_atomic_abort.load(std::memory_order_relaxed); |
nothing calls this directly
no test coverage detected