Skip to content

Commit

Permalink
[bugfix] fix CGRAPH_ASSERT_NOT_NULL function.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Sep 10, 2023
1 parent d8f6e1f commit cab0142
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ GCoordinator<SIZE>::GCoordinator() {
template<CInt SIZE>
CStatus GCoordinator<SIZE>::run() {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(thread_pool_)
status = (SIZE >= 0)
? thread_pool_->createSecondaryThread(SIZE)
: thread_pool_->releaseSecondaryThread((-1) * SIZE);
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 @@ -425,6 +425,7 @@ CStatus GElement::getAsyncResult() {

CStatus GElement::checkSuitable() {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(thread_pool_)

// 包含异步执行的逻辑,不可以loop超过1次
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION((loop_ > CGRAPH_DEFAULT_LOOP_TIMES && this->isAsync()), \
Expand Down
1 change: 0 additions & 1 deletion src/GraphCtrl/GraphElement/GNode/GNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ GNode* GNode::setType(const GNodeType& type) {
CStatus GNode::spawn(const UTaskGroup& tasks, CMSec ttl) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_INIT(true)
CGRAPH_ASSERT_NOT_NULL(thread_pool_)

status = thread_pool_->submit(tasks, ttl);
CGRAPH_FUNCTION_END
Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphPipeline/GPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ CStatus GPipeline::initEnv() {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(event_manager_, element_manager_)

status = repository_.init();
status += schedule_.init();
status = schedule_.init();
CGRAPH_FUNCTION_CHECK_STATUS

auto tp = schedule_.getThreadPool();
Expand All @@ -263,6 +262,7 @@ CStatus GPipeline::initEnv() {
// 设置所有的element 中的thread_pool
repository_.setThreadPool(tp);

status += repository_.init();
CGRAPH_FUNCTION_END
}

Expand Down
6 changes: 5 additions & 1 deletion src/UtilsCtrl/UtilsDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ CVoid __ASSERT_NOT_NULL_THROW_EXCEPTION(T t, Args... args) {

/** 判断传入的多个指针信息,是否为空 */
#define CGRAPH_ASSERT_NOT_NULL(ptr, ...) \
__ASSERT_NOT_NULL(ptr, ##__VA_ARGS__); \
{ \
const CStatus& __cur_status__ = __ASSERT_NOT_NULL(ptr, ##__VA_ARGS__); \
if (unlikely(__cur_status__.isErr())) { return __cur_status__; } \
} \


/** 判断传入的多个指针,是否为空。如果为空,则抛出异常信息 */
#define CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(ptr, ...) \
Expand Down
4 changes: 2 additions & 2 deletions tutorial/T25-Coordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@Contact: [email protected]
@File: T25-Coordinator.cpp
@Time: 2023/9/8 22:01
@Desc: 本例主要演示,通过 GCoordinator 在pipeline执行的过程中,修改
@Desc: 本例主要演示,通过 GCoordinator 在pipeline执行的过程中,修改辅助线程数
***************************/

#include "MyGNode/MyNode1.h"
Expand All @@ -14,7 +14,7 @@ using namespace CGraph;
void tutorial_coordinator() {
GPipelinePtr pipeline = GPipelineFactory::create();
GElementPtr a, b, c, d, f, g, h = nullptr;
GCoordinatorPtr<-2> e_coordinator = nullptr; // 申明一个减少三个辅助线程的 GCoordinator
GCoordinatorPtr<-2> e_coordinator = nullptr; // 申明一个减少2个(-2个)辅助线程的 GCoordinator

UThreadPoolConfig config;
config.default_thread_size_ = 0;
Expand Down

0 comments on commit cab0142

Please sign in to comment.