File tree 1 file changed +5
-5
lines changed
graphbolt/include/graphbolt
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -102,19 +102,19 @@ class Future : public torch::CustomClassHolder {
102
102
* task to avoid spawning a new OpenMP threadpool on each interop thread.
103
103
*/
104
104
template <typename F>
105
- inline auto async (F function) {
105
+ inline auto async (F&& function) {
106
106
using T = decltype (function ());
107
107
#ifdef BUILD_WITH_TASKFLOW
108
- auto future = interop_pool ().async (function);
108
+ auto future = interop_pool ().async (std::move ( function) );
109
109
#else
110
110
auto promise = std::make_shared<std::promise<T>>();
111
111
auto future = promise->get_future ();
112
- at::launch ([= ]() {
112
+ at::launch ([promise, func = std::move (function) ]() {
113
113
if constexpr (std::is_void_v<T>) {
114
- function ();
114
+ func ();
115
115
promise->set_value ();
116
116
} else
117
- promise->set_value (function ());
117
+ promise->set_value (func ());
118
118
});
119
119
#endif
120
120
return c10::make_intrusive<Future<T>>(std::move (future));
You can’t perform that action at this time.
0 commit comments