forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGParam.cpp
More file actions
79 lines (54 loc) · 1.53 KB
/
GParam.cpp
File metadata and controls
79 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: GParam.cpp
@Time: 2023/2/20 22:11
@Desc:
***************************/
#include "GParam.h"
CGRAPH_NAMESPACE_BEGIN
std::vector<std::string> GParam::getBacktrace() {
CGRAPH_THROW_EXCEPTION_BY_CONDITION(!backtrace_enable_, \
"no enable backtrace for [" + key_ + "] param")
std::vector<std::string> traces;
backtrace_lock_.lock();
backtrace_.getUniqueArray(traces);
backtrace_lock_.unlock();
return traces;
}
CStatus GParam::addBacktrace(const std::string& trace) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_RETURN_ERROR_STATUS_BY_CONDITION(!backtrace_enable_, \
"no enable backtrace for [" + key_ + "] param")
// 如果name不为空,则添加name信息。如果name为空,则添加session信息
backtrace_lock_.lock();
backtrace_.uniqueAdd(trace);
backtrace_lock_.unlock();
CGRAPH_FUNCTION_END
}
CVoid GParam::cleanBacktrace() {
if (!backtrace_enable_) {
return;
}
backtrace_lock_.lock();
backtrace_.clear();
backtrace_lock_.unlock();
}
std::string GParam::getKey() const {
return key_;
}
CStatus GParam::setup() {
CGRAPH_EMPTY_FUNCTION
}
CVoid GParam::reset(const CStatus& curStatus) {
}
CVoid GParam::lock() {
_param_shared_lock_.lock();
}
CVoid GParam::unlock() {
_param_shared_lock_.unlock();
}
CBool GParam::tryLock() {
return _param_shared_lock_.try_lock();
}
CGRAPH_NAMESPACE_END