diff --git a/src/distributed/rpc_worker_clients.hpp b/src/distributed/rpc_worker_clients.hpp index e5ed4e669..b0e3af8c5 100644 --- a/src/distributed/rpc_worker_clients.hpp +++ b/src/distributed/rpc_worker_clients.hpp @@ -56,8 +56,10 @@ class RpcWorkerClients { std::vector<std::future<TResult>> futures; for (auto &client : clients_) { if (client.first == skip_worker_id) continue; + futures.emplace_back( - std::async(std::launch::async, execute(client.second))); + std::async(std::launch::async, + [&execute, &client]() { return execute(client.second); })); } return futures; }