Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphAspect/GAspectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GAspectManager::~GAspectManager() {


CStatus GAspectManager::reflect(const internal::GAspectType &type,
const CStatus &curStatus) {
const CStatus &curStatus) const {
CGRAPH_FUNCTION_BEGIN

for (GAspectPtr aspect : aspect_arr_) {
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphAspect/GAspectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GAspectManager : public GAspectObject,
* @return
*/
CStatus reflect(const internal::GAspectType& type,
const CStatus& curStatus = CStatus());
const CStatus& curStatus = CStatus()) const;

CStatus add(GAspectPtr aspect) final;

Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ CStatus GElement::addManagers(GParamManagerPtr paramManager,
}


CStatus GElement::doAspect(const internal::GAspectType& aspectType, const CStatus& curStatus) {
CStatus GElement::doAspect(const internal::GAspectType& aspectType, const CStatus& curStatus) const {
CGRAPH_FUNCTION_BEGIN

// 如果切面管理类为空,或者未添加切面,直接返回
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class GElement : public GElementObject,
* @return
*/
CStatus doAspect(const internal::GAspectType& aspectType,
const CStatus& curStatus = CStatus());
const CStatus& curStatus = CStatus()) const;

/**
* 设置element信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ CVoid GDynamicEngine::analysisDagType() {
CVoid GDynamicEngine::analysisParallelMatrix() {
parallel_element_matrix_.clear();
const auto& config = thread_pool_ ? thread_pool_->getConfig() : UThreadPoolConfig();
CSize thdSize = config.default_thread_size_ + config.secondary_thread_size_;
const CSize& thdSize = config.default_thread_size_ + config.secondary_thread_size_;
CGRAPH_THROW_EXCEPTION_BY_CONDITION(thdSize <= 0,
"default thread size cannot smaller than 1");
CSize taskNumPerThd = total_end_size_ / thdSize + (CSize)(0 != total_end_size_ % thdSize);
const CSize& taskNumPerThd = total_end_size_ / thdSize + static_cast<CSize>(0 != total_end_size_ % thdSize);
CGRAPH_THROW_EXCEPTION_BY_CONDITION(taskNumPerThd == 0,
"task number per thread is 0");

CSize curIndex = 0;
while (curIndex < total_end_size_) {
CSize curEnd = curIndex + taskNumPerThd < total_end_size_ ? curIndex + taskNumPerThd : total_end_size_ ;
const CSize curEnd = curIndex + taskNumPerThd < total_end_size_ ? curIndex + taskNumPerThd : total_end_size_ ;
GElementPtrArr curArr(total_element_arr_.data() + curIndex, total_element_arr_.data() + curEnd);
CGRAPH_THROW_EXCEPTION_BY_CONDITION(curArr.empty(),
"current elements array cannot be empty");
Expand Down Expand Up @@ -233,7 +233,8 @@ CVoid GDynamicEngine::parallelRunAll() {
#else
CVoid GDynamicEngine::parallelRunAll() {
parallel_run_num_ = 0;
for (CIndex i = 0; i < (CIndex)parallel_element_matrix_.size(); i++) {
const CIndex& totalSize = static_cast<CIndex>(parallel_element_matrix_.size());
for (CIndex i = 0; i < totalSize; i++) {
auto& curArr = parallel_element_matrix_[i];
if (curArr.size() > 1) {
for (const auto& element : curArr) {
Expand All @@ -249,7 +250,7 @@ CVoid GDynamicEngine::parallelRunAll() {
}
}

if (parallel_element_matrix_.size() < (CSize)(thread_pool_->getConfig().default_thread_size_)) {
if (parallel_element_matrix_.size() < static_cast<CSize>(thread_pool_->getConfig().default_thread_size_)) {
// 确保所有的 pt 都可以被唤醒,从而快速执行
thread_pool_->wakeupAllThread();
}
Expand All @@ -269,15 +270,15 @@ CVoid GDynamicEngine::parallelRunOne(GElementPtr element) {
return;
}

auto status = element->fatProcessor(CFunctionType::RUN);
const auto& status = element->fatProcessor(CFunctionType::RUN);
if (unlikely(status.isErr())) {
{
CGRAPH_LOCK_GUARD lk(status_lock_);
cur_status_ += status;
}
}

auto finishedSize = parallel_run_num_.fetch_add(1, std::memory_order_release) + 1;
const auto& finishedSize = parallel_run_num_.fetch_add(1, std::memory_order_release) + 1;
if (finishedSize >= total_end_size_ || cur_status_.isErr()) {
CGRAPH_UNIQUE_LOCK lock(locker_.mtx_);
locker_.cv_.notify_one();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CStatus GStaticEngine::setup(const GSortedGElementPtrSet& elements) {
element_mat_.emplace_back(curArr);
GElementPtrArr runnableArr = curArr;
curArr.clear();
for (auto element : runnableArr) {
for (const auto element : runnableArr) {
for (auto cur : element->run_before_) {
if (0 == (--cur->left_depend_)) {
curArr.push_back(cur);
Expand Down
Loading