File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,13 @@ class GlobalThreadPool : public ThreadPool {
2424 **/
2525template <bool isCancellable = false , class Fn , class ... Args>
2626auto async (Fn&& fn, Args&&... args) {
27- std::future ret = GlobalThreadPool::GetInstance ()->Submit (std::forward<Fn>(fn), std::forward<Args>(args)...);
28- return AsyncWrapper<decltype (ret.get ()), isCancellable>{std::move (ret)};
27+ std::future future = GlobalThreadPool::GetInstance ()->Submit (std::forward<Fn>(fn), std::forward<Args>(args)...);
28+ using async_wrapper_t = AsyncWrapper<decltype (future.get ()), isCancellable>;
29+ if constexpr (isCancellable) {
30+ return async_wrapper_t {std::move (future), std::make_shared<std::atomic_bool>(false )};
31+ } else {
32+ return async_wrapper_t {std::move (future)};
33+ }
2934}
3035
3136class async {
You can’t perform that action at this time.
0 commit comments