13 using WorkList_cit = std::vector<WorkUnit>::const_iterator;
15 const WorkList_cit safe_advance(WorkList_cit&
next,
const WorkList_cit
end)
18 std::lock_guard<std::mutex> lock(
mutex);
22 void worker(WorkList_cit&
next,
const WorkList_cit
end)
25 const WorkList_cit last = safe_advance(
next,
end);
26 if (last ==
end) {
return; }
33 Threads(
const size_t n, std::function<
void(
void)>
function)
35 for (
size_t k = 0;
k !=
n;
k++) {
threads.emplace_back(
function ); }
37 ~Threads() {
for (
auto&
t :
threads) {
t.join(); } }
39 std::vector<std::thread>
threads;