diff --git a/mlir/include/mlir/IR/Threading.h b/mlir/include/mlir/IR/Threading.h --- a/mlir/include/mlir/IR/Threading.h +++ b/mlir/include/mlir/IR/Threading.h @@ -71,15 +71,10 @@ // Otherwise, process the elements in parallel. llvm::ThreadPool &threadPool = context->getThreadPool(); size_t numActions = std::min(numElements, threadPool.getThreadCount()); - SmallVector> threadFutures; - threadFutures.reserve(numActions - 1); for (unsigned i = 1; i < numActions; ++i) - threadFutures.emplace_back(threadPool.async(processFn)); + threadPool.async(processFn); processFn(); - - // Wait for all of the threads to finish. - for (std::shared_future &future : threadFutures) - future.wait(); + threadPool.wait(); return failure(processingFailed); }