Another push variant added
This commit is contained in:
parent
4e26232e24
commit
7236426a5b
@ -40,6 +40,7 @@ public:
|
||||
inline ThreadPool();
|
||||
inline ~ThreadPool();
|
||||
inline void push(const std::function<void()> &task);
|
||||
inline void push(std::function<void ()> &&task);
|
||||
inline void
|
||||
start(const long NumOfThreads = std::thread::hardware_concurrency());
|
||||
inline void finish();
|
||||
@ -83,6 +84,12 @@ void ThreadPool::push(const std::function<void()> &task) {
|
||||
_queueCond.notify_one();
|
||||
}
|
||||
|
||||
void ThreadPool::push(std::function<void ()>&& task) {
|
||||
std::unique_lock<decltype(_queueLock)> lg(_queueLock);
|
||||
_tasks.push_back(std::move(task));
|
||||
_queueCond.notify_one();
|
||||
}
|
||||
|
||||
void ThreadPool::start(const long NumOfThreads) {
|
||||
if (!started_already)
|
||||
started_already = true;
|
||||
|
Loading…
Reference in New Issue
Block a user