Skip to content

Commit 93659eb

Browse files
committed
fix case
1 parent 7721234 commit 93659eb

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

include/ylt/easylog.hpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
#pragma once
17+
#include <atomic>
1718
#include <functional>
1819
#include <string_view>
1920
#include <utility>
@@ -75,7 +76,9 @@ class logger {
7576
enable_console_ = enable_console;
7677
}
7778

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+
}
7982

8083
void add_appender(std::function<void(std::string_view)> fn) {
8184
appenders_.emplace_back(std::move(fn));
@@ -85,7 +88,9 @@ class logger {
8588

8689
// set and get
8790
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+
}
8994

9095
void set_console(bool enable) {
9196
enable_console_ = enable;
@@ -122,7 +127,7 @@ class logger {
122127
}
123128
}
124129

125-
Severity min_severity_ =
130+
std::atomic<Severity> min_severity_ =
126131
#if NDEBUG
127132
Severity::WARN;
128133
#else

src/coro_rpc/tests/test_parallel.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ TEST_CASE("test parall coro_rpc call") {
2424

2525
server.register_handler<echo>();
2626
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;
2929
std::vector<std::unique_ptr<coro_rpc::coro_rpc_client>> clients;
3030
clients.resize(client_cnt);
3131
std::atomic<int> connected_cnt = 0;
@@ -77,7 +77,7 @@ TEST_CASE("test parall coro_rpc call2") {
7777
}};
7878
server.register_handler<echo>();
7979
server.async_start();
80-
int client_cnt = 500;
80+
int client_cnt = 200;
8181
std::vector<std::unique_ptr<coro_rpc::coro_rpc_client>> clients;
8282
clients.resize(client_cnt);
8383
std::atomic<int> work_cnt = 0;
@@ -88,7 +88,7 @@ TEST_CASE("test parall coro_rpc call2") {
8888
.via(pool.get_executor())
8989
.start([&](auto&&) {
9090
[](coro_rpc::coro_rpc_client& cli) -> Lazy<void> {
91-
for (int i = 0; i < 1000; ++i)
91+
for (int i = 0; i < 500; ++i)
9292
if (!cli.has_closed()) {
9393
auto result = co_await cli.call<echo>("hello");
9494
if (result.has_value()) {

0 commit comments

Comments
 (0)