Skip to content

Commit 4950664

Browse files
committed
[chron] add some const for var and func
1 parent be353fc commit 4950664

15 files changed

Lines changed: 18 additions & 20 deletions

File tree

‎src/GraphCtrl/GraphElement/GElement.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ CStatus GElement::crashed(const CException& ex) const {
348348
}
349349

350350

351-
CIndex GElement::getThreadIndex() {
351+
CIndex GElement::getThreadIndex() const {
352352
CGRAPH_THROW_EXCEPTION_BY_CONDITION((nullptr == thread_pool_), \
353353
this->getName() + " getThreadIndex with no thread pool") // 理论不可能出现的情况
354354

‎src/GraphCtrl/GraphElement/GElement.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class GElement : public GElementObject,
102102

103103
/**
104104
* 设定绑定的线程id
105-
* @param index,需要绑定的 thread id 信息
105+
* @param index 需要绑定的 thread id 信息
106106
* @return
107107
* @notice 本接口仅保证绑定线程优先调度,但不保证最终一定在绑定线程上执行。若不了解调度机制,不建议使用本接口,否则可能导致运行时阻塞。
108108
*/
@@ -242,7 +242,7 @@ class GElement : public GElementObject,
242242
* @return
243243
* @notice 启动线程返回-1(CGRAPH_MAIN_THREAD_ID),辅助线程返回-2(CGRAPH_SECONDARY_THREAD_COMMON_ID),主线程返回 线程index
244244
*/
245-
CIndex getThreadIndex();
245+
CIndex getThreadIndex() const;
246246

247247
/**
248248
* 判断当前是否超时

‎src/GraphCtrl/GraphElement/GElementManager.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ GElementManagerPtr GElementManager::setThreadPool(UThreadPoolPtr ptr) {
129129
}
130130

131131

132-
CSize GElementManager::calcMaxParaSize() {
132+
CSize GElementManager::calcMaxParaSize() const {
133133
CGRAPH_THROW_EXCEPTION_BY_CONDITION(!GMaxParaOptimizer::match(manager_elements_),
134134
"cannot calculate max parallel size within groups")
135135
return GMaxParaOptimizer::getMaxParaSize(manager_elements_);

‎src/GraphCtrl/GraphElement/GElementManager.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class GElementManager : public GElementObject,
6161

6262
/**
6363
* 构造执行引擎
64-
* @param strategy
6564
* @return
6665
*/
6766
CStatus initEngine();
@@ -77,7 +76,7 @@ class GElementManager : public GElementObject,
7776
* 获取最大的并发数
7877
* @return
7978
*/
80-
CSize calcMaxParaSize();
79+
CSize calcMaxParaSize() const;
8180

8281
/**
8382
* 查看是否可以串行执行

‎src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ GCluster::GCluster() {
1818

1919
CStatus GCluster::run() {
2020
CGRAPH_FUNCTION_BEGIN
21-
for (GElementPtr element : this->children_) {
21+
for (const GElementPtr element : this->children_) {
2222
status = element->fatProcessor(CFunctionType::RUN);
2323
CGRAPH_FUNCTION_CHECK_STATUS
2424
}

‎src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ GCondition::GCondition() {
1919
CStatus GCondition::run() {
2020
CGRAPH_FUNCTION_BEGIN
2121

22-
CIndex index = this->choose();
22+
const CIndex index = this->choose();
2323
if (internal::CGRAPH_CONDITION_LAST_INDEX == index
2424
&& !this->children_.empty()) {
2525
// 如果返回-1,则直接执行最后一个条件(模仿default功能)

‎src/GraphCtrl/GraphElement/GGroup/GCondition/GConditionDefine.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef CGRAPH_GCONDITIONDEFINE_H
1010
#define CGRAPH_GCONDITIONDEFINE_H
1111

12-
#include "../GGroupDefine.h"
1312

1413
CGRAPH_NAMESPACE_BEGIN
1514

‎src/GraphCtrl/GraphElement/GGroup/GGroup.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ GGroup::GGroup() {
1717
CStatus GGroup::init() {
1818
CGRAPH_FUNCTION_BEGIN
1919

20-
for (GElementPtr element : children_) {
20+
for (const GElementPtr element : children_) {
2121
CGRAPH_ASSERT_NOT_NULL(element)
2222
status += element->fatProcessor(CFunctionType::INIT);
2323
}
@@ -31,7 +31,7 @@ CStatus GGroup::init() {
3131
CStatus GGroup::destroy() {
3232
CGRAPH_FUNCTION_BEGIN
3333

34-
for (GElementPtr element : children_) {
34+
for (const GElementPtr element : children_) {
3535
CGRAPH_ASSERT_NOT_NULL(element)
3636
status += element->fatProcessor(CFunctionType::DESTROY);
3737
}
@@ -81,7 +81,7 @@ CVoid GGroup::dumpGroupLabelBegin(std::ostream& oss) {
8181
}
8282

8383

84-
CVoid GGroup::dumpGroupLabelEnd(std::ostream& oss) {
84+
CVoid GGroup::dumpGroupLabelEnd(std::ostream& oss) const {
8585
(void)(this);
8686
oss << "}\n";
8787
}
@@ -93,7 +93,7 @@ CBool GGroup::isSerializable() const {
9393
* 但是在 region和 multiCondition中,有针对性的判断
9494
*/
9595
return std::all_of(children_.begin(), children_.end(),
96-
[](GElementPtr element) {
96+
[](const GElementPtr element) {
9797
return element->isSerializable();
9898
});
9999
}

‎src/GraphCtrl/GraphElement/GGroup/GGroup.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class GGroup : public GElement {
5858
* @param oss
5959
* @return
6060
*/
61-
CVoid dumpGroupLabelEnd(std::ostream& oss);
61+
CVoid dumpGroupLabelEnd(std::ostream& oss) const;
6262

6363
/**
6464
* 判断两个element,是否相互独立

‎src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ GElementPtr GMutable::setThreadPoolEx(UThreadPoolPtr ptr) {
7676
}
7777

7878

79-
CVoid GMutable::setup() {
79+
CVoid GMutable::setup() const {
8080
for (auto* element : children_) {
8181
element->run_before_.clear();
8282
element->dependence_.clear();

0 commit comments

Comments
 (0)