File tree 2 files changed +12
-7
lines changed
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
#pragma once
17
+ #include < atomic>
17
18
#include < functional>
18
19
#include < string_view>
19
20
#include < utility>
@@ -75,7 +76,9 @@ class logger {
75
76
enable_console_ = enable_console;
76
77
}
77
78
78
- bool check_severity (Severity severity) { return severity >= min_severity_; }
79
+ bool check_severity (Severity severity) {
80
+ return severity >= min_severity_.load (std::memory_order::relaxed);
81
+ }
79
82
80
83
void add_appender (std::function<void (std::string_view)> fn) {
81
84
appenders_.emplace_back (std::move (fn));
@@ -85,7 +88,9 @@ class logger {
85
88
86
89
// set and get
87
90
void set_min_severity (Severity severity) { min_severity_ = severity; }
88
- Severity get_min_severity () { return min_severity_; }
91
+ Severity get_min_severity () {
92
+ return min_severity_.load (std::memory_order::relaxed);
93
+ }
89
94
90
95
void set_console (bool enable) {
91
96
enable_console_ = enable;
@@ -122,7 +127,7 @@ class logger {
122
127
}
123
128
}
124
129
125
- Severity min_severity_ =
130
+ std::atomic< Severity> min_severity_ =
126
131
#if NDEBUG
127
132
Severity::WARN;
128
133
#else
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ TEST_CASE("test parall coro_rpc call") {
24
24
25
25
server.register_handler <echo>();
26
26
server.async_start ();
27
- int client_cnt = 500 ;
28
- int64_t work_cnt_tot = thread_cnt * client_cnt * 10 ;
27
+ int client_cnt = 200 ;
28
+ int64_t work_cnt_tot = thread_cnt * client_cnt * 5 ;
29
29
std::vector<std::unique_ptr<coro_rpc::coro_rpc_client>> clients;
30
30
clients.resize (client_cnt);
31
31
std::atomic<int > connected_cnt = 0 ;
@@ -77,7 +77,7 @@ TEST_CASE("test parall coro_rpc call2") {
77
77
}};
78
78
server.register_handler <echo>();
79
79
server.async_start ();
80
- int client_cnt = 500 ;
80
+ int client_cnt = 200 ;
81
81
std::vector<std::unique_ptr<coro_rpc::coro_rpc_client>> clients;
82
82
clients.resize (client_cnt);
83
83
std::atomic<int > work_cnt = 0 ;
@@ -88,7 +88,7 @@ TEST_CASE("test parall coro_rpc call2") {
88
88
.via (pool.get_executor ())
89
89
.start ([&](auto &&) {
90
90
[](coro_rpc::coro_rpc_client& cli) -> Lazy<void > {
91
- for (int i = 0 ; i < 1000 ; ++i)
91
+ for (int i = 0 ; i < 500 ; ++i)
92
92
if (!cli.has_closed ()) {
93
93
auto result = co_await cli.call <echo>(" hello" );
94
94
if (result.has_value ()) {
You can’t perform that action at this time.
0 commit comments