Skip to content

Commit

Permalink
[bugfix] fix empty pipeline crashed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Mar 13, 2024
1 parent 867e304 commit 9c0fd05
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ CVoid GDynamicEngine::mark(const GSortedGElementPtrSet& elements) {


CVoid GDynamicEngine::analysisDagType(const GSortedGElementPtrSet& elements) {
if (front_element_arr_.size() == 1 && total_element_arr_.size() - 1 == linked_size_) {
if (total_element_arr_.empty() || front_element_arr_.size() == 1 && total_element_arr_.size() - 1 == linked_size_) {
/**
* 如果所有的信息中,只有一个是非linkable。则说明只有开头的那个是的,且只有一个开头
* 故,这里将其认定为一条 lineal 的情况
* ps: 只有一element的情况,也会被算到 ALL_SERIAL 中去
* ps: 只有一个或者没有 element的情况,也会被算到 ALL_SERIAL 中去
*/
dag_type_ = internal::GEngineDagType::ALL_SERIAL;
} else if (total_element_arr_.size() == total_end_size_ && front_element_arr_.size() == total_end_size_) {
Expand Down
5 changes: 0 additions & 5 deletions src/GraphCtrl/GraphPipeline/GPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,11 @@ class GPipeline : public GPipelineObject,
* @param elementRef
* @param dependElements
* @return
* @notice Android平台NDK R16B 环境不支持 std::initializer_list<> 和 Args... 混用。参考链接:https://github.com/ChunelFeng/CGraph/pull/116
*/
template<typename TNode, typename ...Args,
c_enable_if_t<std::is_base_of<GTemplateNode<Args ...>, TNode>::value, int> = 0>
CStatus registerGElement(GTemplateNodePtr<Args ...> *elementRef,
#if defined(__ANDROID__)
const GElementPtrSet &dependElements,
#else
const GElementPtrSet &dependElements = std::initializer_list<GElementPtr>(),
#endif
Args... args);

/**
Expand Down
7 changes: 4 additions & 3 deletions src/UtilsCtrl/Trie/UTrieV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
@Desc:
***************************/

#include <stack>

#include "UTrieV2.h"
#include "UTrieNode.h"
#include <cstddef>
#include <stack>

CGRAPH_NAMESPACE_BEGIN

UTrieV2::UTrieV2() {
head_ = CGRAPH_SAFE_MALLOC_COBJECT(UTrieNode)
}


UTrieV2::~UTrieV2() {
clear();
CGRAPH_DELETE_PTR(head_)
Expand Down Expand Up @@ -86,7 +87,7 @@ void UTrieV2::clear() {


void UTrieV2::eraser(const std::string& path) {
if(head_ == nullptr || path.empty()) return;
if (head_ == nullptr || path.empty()) return;
auto *node = head_;
for(const auto &c : path) {
int i = (int)c;
Expand Down
55 changes: 27 additions & 28 deletions tutorial/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@

# 对应tutorial中的内容
set(CGRAPH_TUTORIAL_LIST
# T00-HelloCGraph
# T01-Simple
# T02-Cluster
# T03-Region
# T04-Complex
# T05-Param
# T06-Condition
# T07-MultiPipeline
# T08-Template
# T09-Aspect
# T10-AspectParam
# T11-Singleton
# T12-Function
# T13-Daemon
# T14-Hold
# T15-ElementParam
# T16-MessageSendRecv
# T17-MessagePubSub
# T18-Event
# T19-Cancel
# T20-YieldResume
# T21-MultiCondition
# T22-Timeout
# T23-Some
# T24-Fence
# T25-Coordinator
# T26-Mutable
TU03-TrieV2
T00-HelloCGraph
T01-Simple
T02-Cluster
T03-Region
T04-Complex
T05-Param
T06-Condition
T07-MultiPipeline
T08-Template
T09-Aspect
T10-AspectParam
T11-Singleton
T12-Function
T13-Daemon
T14-Hold
T15-ElementParam
T16-MessageSendRecv
T17-MessagePubSub
T18-Event
T19-Cancel
T20-YieldResume
T21-MultiCondition
T22-Timeout
T23-Some
T24-Fence
T25-Coordinator
T26-Mutable
)


Expand Down
20 changes: 20 additions & 0 deletions tutorial/TU03-Trie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,27 @@ void tutorial_trie() {
}


void tutorial_trie_v2() {
UTrieV2 trieV2;
trieV2.insert("hello");
trieV2.insert("help");
trieV2.insert("cgraph"); // 插入几个单词

CGRAPH_ECHO("find [hello] result is : [%i]", trieV2.find("hello"));
CGRAPH_ECHO("find [cgraph] result is : [%i]", trieV2.find("cgraph"));

trieV2.eraser("hello"); // 删去hello信息
CGRAPH_ECHO("eraser [hello], then find it, result is : [%i]", trieV2.find("hello"));

trieV2.insert("hello"); // 重新插入hello信息
CGRAPH_ECHO("insert [hello] again, then find it, result is : [%i]", trieV2.find("hello"));
}


int main() {
printf("----------------- trie -----------------\n");
tutorial_trie();
printf("----------------- trie v2 -----------------\n");
tutorial_trie_v2();
return 0;
}
33 changes: 0 additions & 33 deletions tutorial/TU03-TrieV2.cpp

This file was deleted.

0 comments on commit 9c0fd05

Please sign in to comment.