@@ -62,26 +62,37 @@ namespace glz
62
62
63
63
std::optional<std::chrono::time_point<std::chrono::steady_clock>> t0{}; // the time of the first event
64
64
65
+ std::atomic<bool > disabled = false ;
65
66
std::mutex mtx{};
66
67
67
68
template <class ... Args>
68
69
requires (sizeof ...(Args) <= 1 )
69
70
void begin (const std::string_view name, Args&&... args) noexcept
70
71
{
72
+ if (disabled) {
73
+ return ;
74
+ }
71
75
duration (name, ' B' , std::forward<Args>(args)...);
72
76
}
73
77
74
78
template <class ... Args>
75
79
requires (sizeof ...(Args) <= 1 )
76
80
void end (const std::string_view name, Args&&... args) noexcept
77
81
{
82
+ if (disabled) {
83
+ return ;
84
+ }
78
85
duration (name, ' E' , std::forward<Args>(args)...);
79
86
}
80
87
81
88
template <class ... Args>
82
89
requires (sizeof ...(Args) <= 1 )
83
90
void duration (const std::string_view name, const char phase, Args&&... args) noexcept
84
91
{
92
+ if (disabled) {
93
+ return ;
94
+ }
95
+
85
96
const auto tnow = std::chrono::steady_clock::now ();
86
97
trace_event* event{};
87
98
{
@@ -104,20 +115,30 @@ namespace glz
104
115
requires (sizeof ...(Args) <= 1 )
105
116
void async_begin (const std::string_view name, Args&&... args) noexcept
106
117
{
118
+ if (disabled) {
119
+ return ;
120
+ }
107
121
async (name, ' b' , std::forward<Args>(args)...);
108
122
}
109
123
110
124
template <class ... Args>
111
125
requires (sizeof ...(Args) <= 1 )
112
126
void async_end (const std::string_view name, Args&&... args) noexcept
113
127
{
128
+ if (disabled) {
129
+ return ;
130
+ }
114
131
async (name, ' e' , std::forward<Args>(args)...);
115
132
}
116
133
117
134
template <class ... Args>
118
135
requires (sizeof ...(Args) <= 1 )
119
136
void async (const std::string_view name, const char phase, Args&&... args) noexcept
120
137
{
138
+ if (disabled) {
139
+ return ;
140
+ }
141
+
121
142
const auto tnow = std::chrono::steady_clock::now ();
122
143
trace_event* event{};
123
144
{
0 commit comments