Commit e46eeb9b authored by Dominik Charousset's avatar Dominik Charousset

Add run_jobs_filtered function for unit testing

parent da90ef78
...@@ -86,7 +86,24 @@ public: ...@@ -86,7 +86,24 @@ public:
return true; return true;
std::rotate(b, i, i + 1); std::rotate(b, i, i + 1);
return true; return true;
}
/// Runs all jobs that satisfy the predicate.
template <class Predicate>
size_t run_jobs_filtered(Predicate predicate) {
size_t result = 0;
while (!jobs.empty()) {
auto b = jobs.begin();
auto e = jobs.end();
auto i = std::find_if(b, e, predicate);
if (i == e)
return result;
if (i != b)
std::rotate(b, i, i + 1);
run_once();
++result;
}
return result;
} }
/// Tries to execute a single event in FIFO order. /// Tries to execute a single event in FIFO order.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment