Skip to content

Commit

Permalink
[bugfix] fix only one element run block when makeSerial() is called.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Dec 15, 2023
1 parent c44db20 commit 411225c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,20 @@ CVoid GDynamicEngine::wait() {


CVoid GDynamicEngine::parallelRunAll() {
// 特殊判定:如果只有一个节点的话,则直接执行就好了
if (1 == total_end_size_) {
cur_status_ = front_element_arr_[0]->fatProcessor(CFunctionType::RUN);
return;
}

/**
* 主要适用于dag是纯并发逻辑的情况
* 直接并发的执行所有的流程,从而减少调度损耗
* 实测效果,在32路纯并行的情况下,整体耗时从 21.5s降低到 12.5s
* 非纯并行逻辑,不走此函数
*/
std::vector<std::future<CStatus>> futures;
futures.reserve(front_element_arr_.size());
futures.reserve(total_end_size_);
for (auto* element : front_element_arr_) {
futures.emplace_back(thread_pool_->commit([element] {
return element->fatProcessor(CFunctionType::RUN);
Expand Down

0 comments on commit 411225c

Please sign in to comment.