mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-03-27 13:50:22 -06: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
@ -606,6 +606,7 @@ bool Client::Read(SocketHolder sockFD, void* buffer, size_t size,
|
||||
if (GET_ERRNO == ERRNO(EWOULDBLOCK) &&
|
||||
(timeout == std::chrono::nanoseconds(0) ||
|
||||
std::chrono::steady_clock::now() - before < timeout)) {
|
||||
std::this_thread::sleep_for(100us);
|
||||
continue;
|
||||
}
|
||||
read_bytes = 0;
|
||||
@ -630,6 +631,7 @@ bool Client::Write(SocketHolder sockFD, const void* buffer, size_t size,
|
||||
if (GET_ERRNO == ERRNO(EWOULDBLOCK) &&
|
||||
(timeout == std::chrono::nanoseconds(0) ||
|
||||
std::chrono::steady_clock::now() - before < timeout)) {
|
||||
std::this_thread::sleep_for(100us);
|
||||
continue;
|
||||
}
|
||||
write_bytes = 0;
|
||||
@ -863,4 +865,4 @@ void Client::OnAllHandlersFinished() {
|
||||
pending_responses.clear();
|
||||
}
|
||||
|
||||
} // namespace Network::ArticBase
|
||||
} // namespace Network::ArticBase
|
||||
|
||||
Loading…
Reference in New Issue
Block a user