when trying to flush the send buffer, use select to wait until it is possible instead of using sleep to retry at a given frequency

This commit is contained in:
Benjamin Sergeant
2019-03-18 14:25:27 -07:00
parent e98634a277
commit d58798e36c
11 changed files with 126 additions and 53 deletions

View File

@ -246,7 +246,7 @@ namespace ix
_webSocket.send(msg.dump(),
[throttle](int current, int total) -> bool
{
std::cout << "Step " << current << " out of " << total << std::endl;
std::cout << "ws_send: Step " << current << " out of " << total << std::endl;
if (throttle)
{
@ -260,7 +260,8 @@ namespace ix
do
{
size_t bufferedAmount = _webSocket.bufferedAmount();
std::cout << bufferedAmount << " bytes left to be sent" << std::endl;
std::cout << "ws_send: " << bufferedAmount
<< " bytes left to be sent" << std::endl;
std::chrono::duration<double, std::milli> duration(10);
std::this_thread::sleep_for(duration);