| 40 | } |
| 41 | |
| 42 | void Async::stop() { |
| 43 | std::lock_guard<std::mutex> guard(_stopMutex); |
| 44 | if (_stopped.exchange(true, std::memory_order_acq_rel)) { |
| 45 | return; |
| 46 | } |
| 47 | if (_thread.isRunning()) { |
| 48 | if (isPoolWorker()) { |
| 49 | _pool->notifyAllWorkers(); |
| 50 | } else { |
| 51 | _workerSemaphore.post(); |
| 52 | } |
| 53 | _thread.shutdown(); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | void Async::run(const std::function<Own<Values>()>& worker, const std::function<void(Own<Values>)>& finisher) { |
| 58 | if (_stopped.load(std::memory_order_acquire)) { |
nothing calls this directly
no test coverage detected