do not busy loop while sending

This commit is contained in:
Benjamin Sergeant
2019-03-14 14:37:43 -07:00
parent f00cf39462
commit d6b49b54d4
3 changed files with 62 additions and 3 deletions

View File

@ -198,6 +198,12 @@ namespace ix
while (!isSendBufferEmpty() && !_requestInitCancellation)
{
sendOnSocket();
// Sleep 10ms between each send so that we dont busy loop
// A better strategy would be to select on the socket to
// check whether we can write to it without blocking
std::chrono::duration<double, std::micro> duration(10);
std::this_thread::sleep_for(duration);
}
}
else if (pollResult == PollResultType_ReadyForRead)