-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] add MultiLinearCondition and MultiParallelCondition. optimize …
…mingw compiler notice.
- Loading branch information
1 parent
6d00108
commit 5a36ae9
Showing
14 changed files
with
202 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/GraphCtrl/GraphElement/GGroup/GCondition/GConditionInclude.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*************************** | ||
@Author: Chunel | ||
@Contact: [email protected] | ||
@File: GConditionInclude.h | ||
@Time: 2023/6/16 22:10 | ||
@Desc: | ||
***************************/ | ||
|
||
#ifndef CGRAPH_GCONDITIONINCLUDE_H | ||
#define CGRAPH_GCONDITIONINCLUDE_H | ||
|
||
#include "GCondition.h" | ||
#include "GMultiLinearCondition.h" | ||
#include "GMultiParallelCondition.h" | ||
|
||
#endif //CGRAPH_GCONDITIONINCLUDE_H |
41 changes: 41 additions & 0 deletions
41
src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiLinearCondition.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*************************** | ||
@Author: Chunel | ||
@Contact: [email protected] | ||
@File: GMultiLinearCondition.cpp | ||
@Time: 2023/6/16 22:09 | ||
@Desc: | ||
***************************/ | ||
|
||
#include "GMultiLinearCondition.h" | ||
|
||
CGRAPH_NAMESPACE_BEGIN | ||
|
||
GMultiLinearCondition::GMultiLinearCondition() { | ||
element_type_ = GElementType::LINEAR_CONDITION; | ||
session_ = URandom<>::generateSession(CGRAPH_STR_LINEAR_CONDITION); | ||
} | ||
|
||
|
||
CStatus GMultiLinearCondition::run() { | ||
CGRAPH_FUNCTION_BEGIN | ||
|
||
for (auto cur: this->group_elements_arr_) { | ||
if (cur->isMatch()) { | ||
// 如果在 | ||
status = cur->fatProcessor(CFunctionType::RUN); | ||
CGRAPH_FUNCTION_CHECK_STATUS | ||
} | ||
} | ||
|
||
CGRAPH_FUNCTION_END | ||
} | ||
|
||
|
||
CIndex GMultiLinearCondition::choose() { | ||
CGRAPH_THROW_EXCEPTION("GMultiLinearCondition no support choose function") | ||
return 0; | ||
} | ||
|
||
CGRAPH_NAMESPACE_END | ||
|
||
|
31 changes: 31 additions & 0 deletions
31
src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiLinearCondition.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*************************** | ||
@Author: Chunel | ||
@Contact: [email protected] | ||
@File: GMultiLinearCondition.h | ||
@Time: 2023/6/16 22:09 | ||
@Desc: | ||
***************************/ | ||
|
||
#ifndef CGRAPH_GMULTILINEARCONDITION_H | ||
#define CGRAPH_GMULTILINEARCONDITION_H | ||
|
||
#include "GCondition.h" | ||
|
||
CGRAPH_NAMESPACE_BEGIN | ||
|
||
class GMultiLinearCondition : public GCondition { | ||
protected: | ||
explicit GMultiLinearCondition(); | ||
|
||
CStatus run() override; | ||
|
||
private: | ||
CIndex choose() final; | ||
|
||
friend class GPipeline; | ||
friend class UAllocator; | ||
}; | ||
|
||
CGRAPH_NAMESPACE_END | ||
|
||
#endif //CGRAPH_GMULTILINEARCONDITION_H |
49 changes: 49 additions & 0 deletions
49
src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiParallelCondition.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*************************** | ||
@Author: Chunel | ||
@Contact: [email protected] | ||
@File: GMultiParallelCondition.cpp | ||
@Time: 2023/6/16 00:05 | ||
@Desc: | ||
***************************/ | ||
|
||
#include "GMultiParallelCondition.h" | ||
|
||
CGRAPH_NAMESPACE_BEGIN | ||
|
||
GMultiParallelCondition::GMultiParallelCondition() { | ||
element_type_ = GElementType::PARALLEL_CONDITION; | ||
session_ = URandom<>::generateSession(CGRAPH_STR_PARALLEL_CONDITION); | ||
} | ||
|
||
|
||
CStatus GMultiParallelCondition::run() { | ||
CGRAPH_FUNCTION_BEGIN | ||
std::vector<std::future<CStatus> > futures; | ||
for (GElementPtr cur : this->group_elements_arr_) { | ||
if (!cur->isMatch()) { | ||
continue; // 不满足条件,则不执行 | ||
} | ||
|
||
futures.emplace_back(this->thread_pool_->commit([cur] { | ||
return cur->fatProcessor(CFunctionType::RUN); | ||
}, cur->getBindingIndex())); | ||
} | ||
|
||
for (auto& fut: futures) { | ||
/** | ||
* 如果有异常值的化,也等待所有内容计算完成后,统一返回 | ||
* 暂时没有处理超时的情况。预计今后会统一处理 | ||
*/ | ||
status += fut.get(); | ||
} | ||
|
||
CGRAPH_FUNCTION_END | ||
} | ||
|
||
|
||
CIndex GMultiParallelCondition::choose() { | ||
CGRAPH_THROW_EXCEPTION("GMultiParallelCondition no need choose function") | ||
return 0; | ||
} | ||
|
||
CGRAPH_NAMESPACE_END |
31 changes: 31 additions & 0 deletions
31
src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiParallelCondition.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*************************** | ||
@Author: Chunel | ||
@Contact: [email protected] | ||
@File: GMultiParallelCondition.h | ||
@Time: 2023/6/16 00:05 | ||
@Desc: | ||
***************************/ | ||
|
||
#ifndef CGRAPH_GMULTIPARALLELCONDITION_H | ||
#define CGRAPH_GMULTIPARALLELCONDITION_H | ||
|
||
#include "GCondition.h" | ||
|
||
CGRAPH_NAMESPACE_BEGIN | ||
|
||
class GMultiParallelCondition : public GCondition { | ||
protected: | ||
explicit GMultiParallelCondition(); | ||
|
||
CStatus run() override; | ||
|
||
private: | ||
CIndex choose() final; | ||
|
||
friend class GPipeline; | ||
friend class UAllocator; | ||
}; | ||
|
||
CGRAPH_NAMESPACE_END | ||
|
||
#endif //CGRAPH_GMULTIPARALLELCONDITION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters