64 auto lock = std::unique_lock{mtx_m};
66 cond_m.wait(lock, [&]() {
return !queue_m.empty() || !running_m; });
70 cond_m.wait(lock, [&]() {
return terminate_m; });
77 runner_m.exec(next_job(lock));
83 auto guard = std::lock_guard{mtx_m};
87 runner_m.stop_all_threads();
96 auto guard = std::lock_guard{mtx_m};
99 throw std::runtime_error(
"Call stop_running first!");
108 auto guard = std::lock_guard{mtx_m};
110 return running_m ==
false;
115 template<
template<
typename>
typename kind_of,
event_c event_t>
119 auto guard = std::lock_guard{mtx_m};
122 std::bind(std::mem_fn<
void(
decltype(queue_m)::value_type&&)>(
123 &
decltype(queue_m)::push_back),
124 &queue_m, std::placeholders::_1));
127 template<
template<
typename>
typename kind_of,
event_c event_t>
131 auto guard = std::lock_guard{mtx_m};
134 std::bind(std::mem_fn<
void(
decltype(queue_m)::value_type&&)>(
135 &
decltype(queue_m)::push_front),
136 &queue_m, std::placeholders::_1));
143 std::condition_variable cond_m;
147 job next_job(
auto& lock)
149 auto j{std::move(queue_m.front())};
164 bool terminate_m{
false};
165 bool running_m{
false};
170 template<
template<
typename>
typename kind_of, event_c event_t>
171 requires kind_c<kind_of>
172 void queue(kind_of<event_t> ke,
auto push_fn)
177 auto j_id = runner_m.next_job_id();
179 push_fn(make_job(j_id, std::move(ke)));
181 if constexpr (internal_event_c<event_t>)
186 else if constexpr (network_event_c<event_t>)
188 auto p_id = ke.md().pipe().id();
190 runner_m.associate_job_to_pipe(j_id, p_id);
193 "Job #{} pushed and associated with Pipe {:X} [# jobs: {}]",
194 j_id, p_id, queue_m.size());
200 std::deque<job> queue_m;