MCPcopy Create free account
hub / github.com/David-Haim/concurrencpp / work_loop

Method work_loop

source/timers/timer_queue.cpp:192–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void 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
230bool timer_queue::shutdown_requested() const noexcept {
231 return m_atomic_abort.load(std::memory_order_relaxed);

Callers

nothing calls this directly

Calls 5

unlockMethod · 0.80
process_timersMethod · 0.80
emptyMethod · 0.45
wait_forMethod · 0.45
wait_untilMethod · 0.45

Tested by

no test coverage detected