Skip to content

Commit df1fc12

Browse files
committed
refactor(common): 优化时间获取函数和 AcquisitionTime 定义
- 在 TotTime 类的 get() 方法中使用 tot_time.load(std::memory_order_relaxed) 替代直接返回 tot_time,以确保多线程环境下数据一致性 - 修改 AcquisitionTime 定义,将其命名为 GetTimeTEMP,以避免潜在的命名冲突
1 parent 8394259 commit df1fc12

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/common/getFunctionTime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TotTime {
1616

1717
void add(int64_t time) { tot_time.fetch_add(time); }
1818

19-
int64_t get() { return tot_time; }
19+
int64_t get() { return tot_time.load(std::memory_order_relaxed); }
2020

2121
void print() {
2222
std::clog << "\033[0m\033[1;31m" << "Total time: " << tot_time.load() / 1e6 << " ms" << "\033[0m" << std::endl;
@@ -42,7 +42,7 @@ class GetTime {
4242
}
4343
};
4444
#ifndef AcquisitionTime
45-
#define AcquisitionTime GetTime();
45+
#define AcquisitionTime GetTime GetTimeTEMP;
4646
#endif
4747

4848
#ifndef PrintFunctionTime

0 commit comments

Comments
 (0)