mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
artic_base_client: Fix high cpu usage (#1789)
Fixes high CPU usage by adding a small sleep to the Client::Read and Client::Write methods
This commit is contained in:
parent
7d19679cc5
commit
03d62efe13
1 changed files with 3 additions and 1 deletions
|
|
@ -606,6 +606,7 @@ bool Client::Read(SocketHolder sockFD, void* buffer, size_t size,
|
||||||
if (GET_ERRNO == ERRNO(EWOULDBLOCK) &&
|
if (GET_ERRNO == ERRNO(EWOULDBLOCK) &&
|
||||||
(timeout == std::chrono::nanoseconds(0) ||
|
(timeout == std::chrono::nanoseconds(0) ||
|
||||||
std::chrono::steady_clock::now() - before < timeout)) {
|
std::chrono::steady_clock::now() - before < timeout)) {
|
||||||
|
std::this_thread::sleep_for(100us);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
read_bytes = 0;
|
read_bytes = 0;
|
||||||
|
|
@ -630,6 +631,7 @@ bool Client::Write(SocketHolder sockFD, const void* buffer, size_t size,
|
||||||
if (GET_ERRNO == ERRNO(EWOULDBLOCK) &&
|
if (GET_ERRNO == ERRNO(EWOULDBLOCK) &&
|
||||||
(timeout == std::chrono::nanoseconds(0) ||
|
(timeout == std::chrono::nanoseconds(0) ||
|
||||||
std::chrono::steady_clock::now() - before < timeout)) {
|
std::chrono::steady_clock::now() - before < timeout)) {
|
||||||
|
std::this_thread::sleep_for(100us);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
write_bytes = 0;
|
write_bytes = 0;
|
||||||
|
|
@ -863,4 +865,4 @@ void Client::OnAllHandlersFinished() {
|
||||||
pending_responses.clear();
|
pending_responses.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Network::ArticBase
|
} // namespace Network::ArticBase
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue