| 82 | // Warning: If the thread pool is stopped then the call will be ignored. |
| 83 | template <typename F, typename... Args> |
| 84 | void SubmitWork(F && func, Args &&... args) |
| 85 | { |
| 86 | auto f = std::bind(std::forward<F>(func), std::forward<Args>(args)...); |
| 87 | { |
| 88 | std::unique_lock lock(m_mutex); |
| 89 | if (m_done) |
| 90 | return; |
| 91 | |
| 92 | m_queue.emplace(std::move(f)); |
| 93 | } |
| 94 | m_condition.notify_one(); |
| 95 | } |
| 96 | |
| 97 | // Stop a ThreadPool. |
| 98 | // Removes the tasks that are not yet started from the queue. |