only bind when args are passed

master
Daniel Kolesa 2017-03-18 18:50:23 +01:00
parent 35cda8872e
commit 3462703b3a
1 changed files with 7 additions and 3 deletions

View File

@ -60,9 +60,13 @@ struct thread_pool {
if (!p_running) {
throw std::runtime_error{"push on stopped thread_pool"};
}
p_tasks.push(
std::bind(std::forward<F>(func), std::forward<A>(args)...)
);
if constexpr(sizeof...(A) == 0) {
p_tasks.push(std::forward<F>(func));
} else {
p_tasks.push(
std::bind(std::forward<F>(func), std::forward<A>(args)...)
);
}
p_cond.notify_one();
} else {
/* non-void-returning funcs return a future */