do the same with the returning version

This commit is contained in:
q66 2017-03-18 18:53:57 +01:00
parent 3462703b3a
commit 795234c476

View file

@ -70,9 +70,14 @@ struct thread_pool {
p_cond.notify_one(); p_cond.notify_one();
} else { } else {
/* non-void-returning funcs return a future */ /* non-void-returning funcs return a future */
std::packaged_task<R> t{ std::packaged_task<R> t;
std::bind(std::forward<F>(func), std::forward<A>(args)...) if constexpr(sizeof...(A) == 0) {
}; t = std::packaged_task<R>{std::forward<F>(func)};
} else {
t = std::packaged_task<R>{
std::bind(std::forward<F>(func), std::forward<A>(args)...)
};
}
auto ret = t.get_future(); auto ret = t.get_future();
std::unique_lock<std::mutex> l{p_lock}; std::unique_lock<std::mutex> l{p_lock};
if (!p_running) { if (!p_running) {