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/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ CStatus GElement::crashed(const CException& ex) const {
}


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

Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphElement/GElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class GElement : public GElementObject,

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

/**
* 判断当前是否超时
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElementManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ GElementManagerPtr GElementManager::setThreadPool(UThreadPoolPtr ptr) {
}


CSize GElementManager::calcMaxParaSize() {
CSize GElementManager::calcMaxParaSize() const {
CGRAPH_THROW_EXCEPTION_BY_CONDITION(!GMaxParaOptimizer::match(manager_elements_),
"cannot calculate max parallel size within groups")
return GMaxParaOptimizer::getMaxParaSize(manager_elements_);
Expand Down
3 changes: 1 addition & 2 deletions src/GraphCtrl/GraphElement/GElementManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class GElementManager : public GElementObject,

/**
* 构造执行引擎
* @param strategy
* @return
*/
CStatus initEngine();
Expand All @@ -77,7 +76,7 @@ class GElementManager : public GElementObject,
* 获取最大的并发数
* @return
*/
CSize calcMaxParaSize();
CSize calcMaxParaSize() const;

/**
* 查看是否可以串行执行
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GCluster::GCluster() {

CStatus GCluster::run() {
CGRAPH_FUNCTION_BEGIN
for (GElementPtr element : this->children_) {
for (const GElementPtr element : this->children_) {
status = element->fatProcessor(CFunctionType::RUN);
CGRAPH_FUNCTION_CHECK_STATUS
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GCondition::GCondition() {
CStatus GCondition::run() {
CGRAPH_FUNCTION_BEGIN

CIndex index = this->choose();
const CIndex index = this->choose();
if (internal::CGRAPH_CONDITION_LAST_INDEX == index
&& !this->children_.empty()) {
// 如果返回-1,则直接执行最后一个条件(模仿default功能)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef CGRAPH_GCONDITIONDEFINE_H
#define CGRAPH_GCONDITIONDEFINE_H

#include "../GGroupDefine.h"

CGRAPH_NAMESPACE_BEGIN

Expand Down
8 changes: 4 additions & 4 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GGroup::GGroup() {
CStatus GGroup::init() {
CGRAPH_FUNCTION_BEGIN

for (GElementPtr element : children_) {
for (const GElementPtr element : children_) {
CGRAPH_ASSERT_NOT_NULL(element)
status += element->fatProcessor(CFunctionType::INIT);
}
Expand All @@ -31,7 +31,7 @@ CStatus GGroup::init() {
CStatus GGroup::destroy() {
CGRAPH_FUNCTION_BEGIN

for (GElementPtr element : children_) {
for (const GElementPtr element : children_) {
CGRAPH_ASSERT_NOT_NULL(element)
status += element->fatProcessor(CFunctionType::DESTROY);
}
Expand Down Expand Up @@ -81,7 +81,7 @@ CVoid GGroup::dumpGroupLabelBegin(std::ostream& oss) {
}


CVoid GGroup::dumpGroupLabelEnd(std::ostream& oss) {
CVoid GGroup::dumpGroupLabelEnd(std::ostream& oss) const {
(void)(this);
oss << "}\n";
}
Expand All @@ -93,7 +93,7 @@ CBool GGroup::isSerializable() const {
* 但是在 region和 multiCondition中,有针对性的判断
*/
return std::all_of(children_.begin(), children_.end(),
[](GElementPtr element) {
[](const GElementPtr element) {
return element->isSerializable();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GGroup : public GElement {
* @param oss
* @return
*/
CVoid dumpGroupLabelEnd(std::ostream& oss);
CVoid dumpGroupLabelEnd(std::ostream& oss) const;

/**
* 判断两个element,是否相互独立
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GElementPtr GMutable::setThreadPoolEx(UThreadPoolPtr ptr) {
}


CVoid GMutable::setup() {
CVoid GMutable::setup() const {
for (auto* element : children_) {
element->run_before_.clear();
element->dependence_.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GMutable : public GGroup {
* 将数据进行恢复
* @return
*/
CVoid setup();
CVoid setup() const;

GElementPtr setThreadPoolEx(UThreadPoolPtr ptr) final;

Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ CBool GRegion::isSeparate(GElementCPtr a, GElementCPtr b) const {
}


CSize GRegion::trim() {
CSize GRegion::trim() const {
CGRAPH_ASSERT_INIT_THROW_ERROR(false)
CSize result = 0;
if (manager_) {
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GRegion : public GGroup {
* 修剪冗余的连边信息
* @return
*/
CSize trim();
CSize trim() const;

protected:
explicit GRegion();
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GNode/GNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GNodePtr GNode::setType(const GNodeType& type) {
}


CStatus GNode::spawn(const UTaskGroup& tasks, CMSec ttl) {
CStatus GNode::spawn(const UTaskGroup& tasks, const CMSec ttl) const {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_INIT(true)
CGRAPH_ASSERT_NOT_NULL(thread_pool_)
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GNode/GNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GNode : public GElement {
* @param ttl
* @return
*/
CStatus spawn(const UTaskGroup& tasks, CMSec ttl = CGRAPH_MAX_BLOCK_TTL);
CStatus spawn(const UTaskGroup& tasks, CMSec ttl = CGRAPH_MAX_BLOCK_TTL) const;

private:
GNodeType node_type_ { GNodeType::BASIC }; // 节点类型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,12 @@ CVoid GDynamicEngine::prepareRun() {

template<typename Pred>
CBool GDynamicEngine::isFastFinished(Pred&& check) {
CBool result = false;
const auto epoch = thread_pool_->getConfig().pipeline_wait_busy_epoch_;
for (auto i = 0; i < epoch; i++) {
if (check()) {
result = true;
break;
}
auto epoch = thread_pool_->getConfig().pipeline_wait_busy_epoch_;
while (epoch-- > 0 && !check()) {
CGRAPH_YIELD();
}

return result;
return epoch >= 0;
}

CGRAPH_NAMESPACE_END
1 change: 1 addition & 0 deletions test/Performance/test-performance-04.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void test_performance_04() {
config.primary_thread_busy_epoch_ = 500;
config.primary_thread_empty_interval_ = 0;
config.deliver_running_primary_thread_enable_ = true;
config.pipeline_wait_busy_epoch_ = 100;
pipeline->setUniqueThreadPoolConfig(config);

// 实现一个全连接
Expand Down
Loading