Skip to content

Commit

Permalink
[compile] add ninja compile mothed
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Dec 27, 2023
1 parent c760da1 commit 4fcf3fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CGraph-ninja-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

rm -rf build

cmake -G Ninja -Bbuild
cd build || { ! echo "enter ninja-build failed"; exit 1; }
ninja
echo -e "\033[34m congratulations, automatic compile CGraph finish by ninja... \033[0m"
14 changes: 7 additions & 7 deletions src/GraphCtrl/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ GElementPtr GElement::setTimeout(CMSec timeout, GElementTimeoutStrategy strategy
GElementRef GElement::operator--(int) noexcept {
try {
this->setVisible(true);
} catch (const CException& ex) {
} catch (const CException&) {
CGRAPH_ECHO("[warning] default set visible failed.");
}

Expand Down Expand Up @@ -129,7 +129,7 @@ GElementRef GElement::operator&(GElementPtr element) {
GElement& GElement::operator*(CSize loop) noexcept {
try {
this->setLoop(loop);
} catch (const CException& ex) {
} catch (const CException&) {
CGRAPH_ECHO("[warning] default set loop failed.");
}

Expand All @@ -138,7 +138,7 @@ GElement& GElement::operator*(CSize loop) noexcept {


CBool GElement::isRunnable() const {
return 0 >= this->left_depend_.load(std::memory_order_consume) && !this->done_;
return 0 >= this->left_depend_.load(std::memory_order_acquire) && !this->done_;
}


Expand Down Expand Up @@ -247,7 +247,7 @@ CStatus GElement::fatProcessor(const CFunctionType& type) {
}

trigger_times_++; // 记录实际上触发了多少次,而不是正式执行了多少次
for (CSize i = 0; i < this->loop_ && GElementState::NORMAL == cur_state_.load(std::memory_order_consume); i++) {
for (CSize i = 0; i < this->loop_ && GElementState::NORMAL == cur_state_.load(std::memory_order_acquire); i++) {
/** 执行带切面的run方法 */
status = doAspect(GAspectType::BEGIN_RUN);
CGRAPH_FUNCTION_CHECK_STATUS
Expand Down Expand Up @@ -319,10 +319,10 @@ CBool GElement::isTimeout() const {
* 1. 如果当前节点超时,则认定为超时
* 2. 如果当前节点所在的group超时,则也认定为超时
*/
CBool result = (GElementState::TIMEOUT == cur_state_.load(std::memory_order_consume));
CBool result = (GElementState::TIMEOUT == cur_state_.load(std::memory_order_acquire));
GElementPtr belong = this->belong_;
while (!result && belong) {
result = (GElementState::TIMEOUT == belong->cur_state_.load(std::memory_order_consume));
result = (GElementState::TIMEOUT == belong->cur_state_.load(std::memory_order_acquire));
belong = belong->belong_;
}

Expand Down Expand Up @@ -420,7 +420,7 @@ CVoid GElement::dumpPerfInfo(std::ostream& oss) {
CVoid GElement::checkYield() {
std::unique_lock<std::mutex> lk(yield_mutex_);
this->yield_cv_.wait(lk, [this] {
return GElementState::YIELD != cur_state_.load(std::memory_order_consume);
return GElementState::YIELD != cur_state_.load(std::memory_order_acquire);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CStatus GDynamicEngine::afterRunCheck() {
* 纯并行度逻辑,肯定会所有都跑一遍,并且等待全部结束,
* 故,不需要判断。
*/
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(run_element_size_.load(std::memory_order_consume) != total_element_arr_.size(), \
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(run_element_size_.load(std::memory_order_acquire) != total_element_arr_.size(), \
"dynamic engine run element size not match...")
for (GElementPtr element : total_element_arr_) {
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(!element->done_, "dynamic engine run check failed...")
Expand All @@ -84,7 +84,7 @@ CVoid GDynamicEngine::asyncRunAndWait() {

CVoid GDynamicEngine::beforeRun() {
finished_end_size_ = 0;
run_element_size_ = 0;
run_element_size_.store(0, std::memory_order_release);
cur_status_.reset();
for (GElementPtr element : total_element_arr_) {
element->beforeRun();
Expand Down Expand Up @@ -119,7 +119,7 @@ CStatus GDynamicEngine::process(GElementPtr element, CBool affinity) {

CVoid GDynamicEngine::afterElementRun(GElementPtr element) {
element->done_ = true;
run_element_size_++;
run_element_size_.fetch_add(1, std::memory_order_release);

std::vector<GElementPtr> ready; // 表示可以执行的列表信息
for (auto* cur : element->run_before_) {
Expand Down

0 comments on commit 4fcf3fc

Please sign in to comment.