mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
微调
This commit is contained in:
parent
8a13571312
commit
32f88c8353
@ -21,7 +21,7 @@ constexpr std::size_t const min_sz = 128;
|
||||
constexpr std::size_t const max_sz = 1024 * 16;
|
||||
|
||||
std::atomic<bool> is_quit__{ false };
|
||||
std::atomic<std::size_t> size_per_1s__{ 0 };
|
||||
std::atomic<std::size_t> size_counter__{ 0 };
|
||||
|
||||
using msg_que_t = ipc::chan<ipc::relat::single, ipc::relat::single, ipc::trans::unicast>;
|
||||
|
||||
@ -49,9 +49,8 @@ void do_counting() {
|
||||
if (i % 10) continue;
|
||||
i = 0;
|
||||
std::cout
|
||||
<< speed_of(size_per_1s__.load(std::memory_order_acquire))
|
||||
<< speed_of(size_counter__.exchange(0, std::memory_order_relaxed))
|
||||
<< std::endl;
|
||||
size_per_1s__.store(0, std::memory_order_release);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +75,7 @@ void do_send() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
size_per_1s__.fetch_add(sz, std::memory_order_release);
|
||||
size_counter__.fetch_add(sz, std::memory_order_relaxed);
|
||||
std::this_thread::yield();
|
||||
}
|
||||
counting.join();
|
||||
@ -97,7 +96,7 @@ void do_recv() {
|
||||
while (!is_quit__.load(std::memory_order_acquire)) {
|
||||
auto msg = que__.recv();
|
||||
if (msg.empty()) break;
|
||||
size_per_1s__.fetch_add(msg.size(), std::memory_order_release);
|
||||
size_counter__.fetch_add(msg.size(), std::memory_order_relaxed);
|
||||
}
|
||||
counting.join();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user