From fab8457e6b117be26e23171b649a1bfda14531b2 Mon Sep 17 00:00:00 2001 From: Qiao Longfei Date: Sat, 26 Jan 2019 23:12:23 +0800 Subject: [PATCH] code optimize --- .../details/async_ssa_graph_executor.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/framework/details/async_ssa_graph_executor.cc b/paddle/fluid/framework/details/async_ssa_graph_executor.cc index ba2e90d0528..7dc269242f2 100644 --- a/paddle/fluid/framework/details/async_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/async_ssa_graph_executor.cc @@ -68,20 +68,18 @@ FeedFetchList AsyncSSAGraphExecutor::Run( if (pool_) { run_futures.emplace_back(pool_->enqueue(std::move(call))); + for (auto &f : run_futures) { + if (exception_holder_.IsCaught()) { + f.wait(); + } else { + fetch_data.emplace_back(std::move(f.get())); + } + } } else { fetch_data.emplace_back(std::move(call())); } } - if (pool_) { - for (auto &f : run_futures) { - if (exception_holder_.IsCaught()) { - f.wait(); - } else { - fetch_data.emplace_back(std::move(f.get())); - } - } - } if (exception_holder_.IsCaught()) { exception_holder_.ReThrow(); } -- GitLab