updated return type

This commit is contained in:
sascha 2026-05-21 12:39:25 +02:00
parent 194e139e8b
commit ddf19bbf07
1 changed files with 3 additions and 3 deletions

View File

@ -59,8 +59,8 @@ public:
* @param args Passed arguments * @param args Passed arguments
*/ */
template <typename F, typename... Args> template <typename F, typename... Args>
auto schedule(F&& func, Args&&... args) -> result_fut<std::result_of_t<F(cancel_token&, Args...)>> { auto schedule(F&& func, Args&&... args) -> result_fut<std::invoke_result_t<F, cancel_token&, Args...>> {
using return_type = std::result_of_t<F(cancel_token&, Args...)>; using return_type = std::invoke_result_t<F, cancel_token&, Args...>;
const auto token = std::make_shared<cancel_token>(); const auto token = std::make_shared<cancel_token>();
auto task_ptr = std::make_shared<std::packaged_task<return_type()>>( auto task_ptr = std::make_shared<std::packaged_task<return_type()>>(
@ -73,7 +73,7 @@ public:
if (!running_) { if (!running_) {
return failure(std::string("Thread pool is shut down, cannot schedule new tasks.")); return failure(std::string("Thread pool is shut down, cannot schedule new tasks."));
} }
tasks_.emplace_back([task_ptr, token] { tasks_.emplace_back([task_ptr] {
try { (*task_ptr)(); } try { (*task_ptr)(); }
catch (...) { /* Prevent exception escape */ } catch (...) { /* Prevent exception escape */ }
}, token); }, token);