Skip to content

Commit d58a5e3

Browse files
committed
Thread/ThreadPool: call(Function, Args...) -> call(Function)
1 parent f870237 commit d58a5e3

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

modules/Thread/ThreadPool.mpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ export namespace CppUtils::Thread
4040
worker.stop();
4141
}
4242

43-
template<class Func, class... Args>
44-
inline auto call(Func&& function, Args&&... args) -> std::future<std::invoke_result_t<Func, Args...>>
43+
inline auto call(auto&& function) -> std::future<std::invoke_result_t<std::decay_t<decltype(function)>>>
4544
{
46-
using ReturnType = std::invoke_result_t<Func, Args...>;
47-
auto task = std::make_shared<std::packaged_task<ReturnType()>>([this, function = std::forward<Func>(function), ... args = std::forward<Args>(args)]() {
45+
using ReturnType = std::invoke_result_t<std::decay_t<decltype(function)>>;
46+
auto task = std::make_shared<std::packaged_task<ReturnType()>>([this, function = std::forward<decltype(function)>(function)]() {
4847
try
4948
{
50-
std::invoke(function, std::move(args)...);
49+
std::invoke(function);
5150
}
5251
catch (...)
5352
{

0 commit comments

Comments
 (0)