diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-02-22 01:36:46 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-02-23 01:47:38 +0100 |
| commit | 5980b854a710d4c63b3077f73cd671b1d388939b (patch) | |
| tree | 55525c745ff6e4586cad148d6a9d368e30bc8c16 /src/lib/job_manager.cc | |
| parent | 1e50de1e7f3eb2b22fd1df815722355a1f853088 (diff) | |
Add JobManager::cancel_all_jobs().
Diffstat (limited to 'src/lib/job_manager.cc')
| -rw-r--r-- | src/lib/job_manager.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 3fac8e6fa..a53eb6ebd 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -348,3 +348,21 @@ JobManager::resume () _paused = false; _schedule_condition.notify_all(); } + + +void +JobManager::cancel_all_jobs() +{ + boost::mutex::scoped_lock lm(_mutex); + auto jobs = _jobs; + lm.unlock(); + + /* Calling Job::cancel() will result in JobManager::job_finished() being called, so we need + * to do this without a lock on _mutex. I think the worst case is that we fail to stop a + * job that got started since we lm.unlock()ed. + */ + for (auto job: jobs) { + job->cancel(); + } +} + |
