| 44 | } |
| 45 | |
| 46 | std::size_t ConcurrentQueue::cancelPending() |
| 47 | { |
| 48 | decltype(_queue) oldQueue; |
| 49 | { |
| 50 | const std::lock_guard<std::mutex> lock(queueMutex); |
| 51 | // The mutex locking time is lower with swap() compared to assigning a |
| 52 | // temporary (which destroys _queue's elements and deallocates memory). |
| 53 | _queue.swap(oldQueue); |
| 54 | } |
| 55 | |
| 56 | const auto size = oldQueue.size(); |
| 57 | if (size != 0) |
| 58 | finalizeJobs(size); |
| 59 | return size; |
| 60 | } |
| 61 | |
| 62 | void ConcurrentQueue::waitAll() const |
| 63 | { |
no outgoing calls