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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ if __name__ == '__main__':
* 提供 C# 和 Java 版本
* 提供 `CODE_OF_CONDUCT.md` 文档

[2025.07.23 - v3.1.2 - Chunel]
* 优化 切面功能

</details>

------------
Expand Down
4 changes: 4 additions & 0 deletions python/wrapper/PywGAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class PywGAspect : public CGraph::GAspect {
CVoid enterCrashed() override {
PYBIND11_OVERLOAD(CVoid, GAspect, enterCrashed);
}

CVoid enterTimeout() override {
PYBIND11_OVERLOAD(CVoid, GAspect, enterTimeout);
}
};

#endif //CGRAPH_PYWGASPECT_H
4 changes: 4 additions & 0 deletions src/GraphCtrl/GraphAspect/GAspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ CVoid GAspect::finishDestroy(const CStatus& curStatus) {
CVoid GAspect::enterCrashed() {
}


CVoid GAspect::enterTimeout() {
}

CGRAPH_NAMESPACE_END
8 changes: 7 additions & 1 deletion src/GraphCtrl/GraphAspect/GAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ class GAspect : public GAspectObject {
virtual CVoid finishDestroy(const CStatus& curStatus);

/**
* 进入crash的逻辑
* 进入crash切面的逻辑
* @return
*/
virtual CVoid enterCrashed();

/**
* 进入 timeout状态的切面逻辑
* @return
*/
virtual CVoid enterTimeout();
};

using GAspectPtr = GAspect *;
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphAspect/GAspectDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum class GAspectType {
FINISH_RUN = 3,
BEGIN_DESTROY = 4,
FINISH_DESTROY = 5,
ENTER_TIMEOUT = 98,
ENTER_CRASHED = 99,
};

Expand Down
17 changes: 10 additions & 7 deletions src/GraphCtrl/GraphAspect/GAspectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,28 @@ CStatus GAspectManager::reflect(const internal::GAspectType &type,
* 仅针对Begin对应的内容,进行返回值判断
* run()方法切面更容易被执行,故放在最前方判断
*/
case internal::GAspectType::BEGIN_RUN :
case internal::GAspectType::BEGIN_RUN:
status = aspect->beginRun();
break;
case internal::GAspectType::FINISH_RUN :
case internal::GAspectType::FINISH_RUN:
aspect->finishRun(curStatus);
break;
case internal::GAspectType::BEGIN_INIT :
case internal::GAspectType::BEGIN_INIT:
status = aspect->beginInit();
break;
case internal::GAspectType::FINISH_INIT :
case internal::GAspectType::FINISH_INIT:
aspect->finishInit(curStatus);
break;
case internal::GAspectType::BEGIN_DESTROY :
case internal::GAspectType::BEGIN_DESTROY:
status = aspect->beginDestroy();
break;
case internal::GAspectType::FINISH_DESTROY :
case internal::GAspectType::FINISH_DESTROY:
aspect->finishDestroy(curStatus);
break;
case internal::GAspectType::ENTER_CRASHED :
case internal::GAspectType::ENTER_TIMEOUT:
aspect->enterTimeout();
break;
case internal::GAspectType::ENTER_CRASHED:
aspect->enterCrashed();
break;
default:
Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ CStatus GElement::asyncRun() {
if (std::future_status::ready == futStatus) {
status = getAsyncResult();
} else {
doAspect(internal::GAspectType::ENTER_TIMEOUT);
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION( GElementTimeoutStrategy::AS_ERROR == timeout_strategy_, \
"[" + name_ + "] running time more than [" + std::to_string(timeout_) + "]ms")
cur_state_.store(GElementState::TIMEOUT, std::memory_order_release);
Expand Down
Loading