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

Method loop_impl

source/executors/manual_executor.cpp:47–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47size_t manual_executor::loop_impl(size_t max_count) {
48 if (max_count == 0) {
49 return 0;
50 }
51
52 size_t executed = 0;
53
54 while (true) {
55 if (executed == max_count) {
56 break;
57 }
58
59 std::unique_lock<decltype(m_lock)> lock(m_lock);
60 if (m_abort) {
61 break;
62 }
63
64 if (m_tasks.empty()) {
65 break;
66 }
67
68 auto task = std::move(m_tasks.front());
69 m_tasks.pop_front();
70 lock.unlock();
71
72 task();
73 ++executed;
74 }
75
76 if (shutdown_requested()) {
77 details::throw_runtime_shutdown_exception(name);
78 }
79
80 return executed;
81}
82
83size_t manual_executor::loop_until_impl(size_t max_count, std::chrono::time_point<std::chrono::system_clock> deadline) {
84 if (max_count == 0) {

Callers

nothing calls this directly

Calls 5

taskFunction · 0.85
shutdown_requestedFunction · 0.85
pop_frontMethod · 0.80
unlockMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected