diff options
author | Max Kellermann <max@musicpd.org> | 2021-03-07 18:17:16 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-03-07 18:20:59 +0100 |
commit | cf108c389f88deb6fbc70390b9877a9df6e8701e (patch) | |
tree | 889d4113610b773d9d882449d8db36033d37b910 | |
parent | 90d97053a867b78ecd5b52daa1935e04cf3beeb2 (diff) |
win32/ComWorker: remove parameter passing from Async()
Parameters should better be captured. This removes some complexity
from Async().
-rw-r--r-- | src/win32/ComWorker.hxx | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/win32/ComWorker.hxx b/src/win32/ComWorker.hxx index f7e29a395..3fa0db44a 100644 --- a/src/win32/ComWorker.hxx +++ b/src/win32/ComWorker.hxx @@ -65,24 +65,19 @@ public: COMWorker(const COMWorker &) = delete; COMWorker &operator=(const COMWorker &) = delete; - template <typename Function, typename... Args> - auto Async(Function &&function, Args &&...args) { - using R = std::invoke_result_t<std::decay_t<Function>, - std::decay_t<Args>...>; + template<typename Function> + auto Async(Function &&function) { + using R = std::invoke_result_t<std::decay_t<Function>>; auto promise = std::make_shared<Promise<R>>(); auto future = promise->get_future(); thread.Push([function = std::forward<Function>(function), - args = std::make_tuple(std::forward<Args>(args)...), promise = std::move(promise)]() mutable { try { if constexpr (std::is_void_v<R>) { - std::apply(std::forward<Function>(function), - std::move(args)); + std::invoke(std::forward<Function>(function)); promise->set_value(); } else { - promise->set_value(std::apply( - std::forward<Function>(function), - std::move(args))); + promise->set_value(std::invoke(std::forward<Function>(function))); } } catch (...) { promise->set_exception(std::current_exception()); |