Skip to content

Commit e395e48

Browse files
committed
[chg] change gsome virtual api, from getWaitTime to getThreshold
1 parent 6229d95 commit e395e48

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

python/tutorial/MyGSome/MySome.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
from pycgraph import GSome
1010

1111
class MyGSome(GSome):
12-
def getWaitNum(self):
12+
def getThreshold(self):
1313
return 1

python/wrapper/PywGSome.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class PywGSome : public CGraph::GSome {
2121
}
2222
~PywGSome() override = default;
2323

24-
CSize getWaitNum() override {
25-
PYBIND11_OVERLOAD_PURE(CSize, PywGSome, getWaitNum);
24+
CSize getThreshold() override {
25+
PYBIND11_OVERLOAD_PURE(CSize, PywGSome, getThreshold);
2626
}
2727
};
2828

2929

3030
PYCGRAPH_DECLARE_GGROUP_INTERFACE_CLASS(PywGSome,
31-
CSize getWaitNum() override {
32-
PYBIND11_OVERLOAD_PURE(CSize, PywGSomeInterface, getWaitNum);
31+
CSize getThreshold() override {
32+
PYBIND11_OVERLOAD_PURE(CSize, PywGSomeInterface, getThreshold);
3333
});
3434

3535
#endif //CGRAPH_PYWGSOME_H

src/GraphCtrl/GraphElement/GGroup/GSome/GSome.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ CStatus GSome::addElementEx(GElementPtr element) {
4040
CStatus GSome::run() {
4141
CGRAPH_FUNCTION_BEGIN
4242

43-
wait_num_ = getWaitNum();
44-
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(wait_num_ > children_.size(),
45-
"num is bigger than elements size.");
43+
threshold_ = getThreshold();
44+
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(threshold_ > children_.size(),
45+
"threshold cannot bigger than elements size.");
4646
cur_status_.reset();
4747

4848
/**
@@ -57,7 +57,7 @@ CStatus GSome::run() {
5757
const auto& curStatus = element->fatProcessor(CFunctionType::RUN);
5858
CGRAPH_UNIQUE_LOCK lock(lock_);
5959
cur_status_ += curStatus;
60-
if (--wait_num_ == 0 || cur_status_.isErr()) {
60+
if (--threshold_ == 0 || cur_status_.isErr()) {
6161
cv_.notify_one();
6262
}
6363
}
@@ -67,7 +67,7 @@ CStatus GSome::run() {
6767
thread_pool_->wakeupAllThread();
6868
CGRAPH_UNIQUE_LOCK lock(lock_);
6969
cv_.wait(lock, [this] {
70-
return wait_num_ == 0 || cur_status_.isErr();
70+
return threshold_ == 0 || cur_status_.isErr();
7171
});
7272

7373
for (auto* element : children_) {
@@ -108,7 +108,7 @@ CStatus GSome::checkSuitable() {
108108
status = GElement::checkSuitable();
109109
CGRAPH_FUNCTION_CHECK_STATUS
110110

111-
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION((CGRAPH_DEFAULT_LOOP_TIMES != loop_), "GSome cannot set loop > 1.")
111+
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(CGRAPH_DEFAULT_LOOP_TIMES != loop_, "GSome cannot set loop > 1.")
112112
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(std::any_of(children_.begin(), children_.end(), [](GElementPtr ptr) {
113113
return !ptr->isAsync();
114114
}), "GSome contains async node only.")

src/GraphCtrl/GraphElement/GGroup/GSome/GSome.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class GSome : public GGroup {
2020
protected:
2121
/**
2222
* 设定 wait_num 个数
23-
* 当前 group 执行完成 wait_num 个后,就可以继续执行
23+
* 当前 group 执行完成 threshold 个后,就可以继续执行
2424
* @return
2525
*/
26-
virtual CSize getWaitNum() = 0;
26+
virtual CSize getThreshold() = 0;
2727

2828
protected:
2929
explicit GSome();
@@ -41,7 +41,7 @@ class GSome : public GGroup {
4141
CStatus addElementEx(GElementPtr element) override;
4242

4343
private:
44-
CSize wait_num_ {0}; // 还剩的触发结束的个数
44+
CSize threshold_ {0}; // 还剩的触发结束的个数
4545
CStatus cur_status_ ; // 记录异步时刻的当前状态信息
4646

4747
std::mutex lock_;

tutorial/MyGSome/MySome.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class MySome : public CGraph::GSome {
1515
protected:
16-
CSize getWaitNum() override {
16+
CSize getThreshold() override {
1717
/**
1818
* 执行完 1个之后,当前的 GSome 就继续往后执行
1919
* 其余的 element,会在 pipeline 结束之前,执行完成。

0 commit comments

Comments
 (0)