| 38 | } |
| 39 | } |
| 40 | ~ThreadPool() |
| 41 | { |
| 42 | { |
| 43 | std::unique_lock<std::mutex> lock(mutex); |
| 44 | stop = true; |
| 45 | } |
| 46 | condition.notify_all(); |
| 47 | for (size_t i = 0; i < threads.size(); i++) threads[i].join(); |
| 48 | } |
| 49 | template<class Fn, class... Args> |
| 50 | std::future<std::invoke_result_t<Fn, Args...>> enqueue(Fn&& fn, Args&&... args) |
| 51 | { |