Skip to content

Commit

Permalink
feat: replace blocking sleep with co_await
Browse files Browse the repository at this point in the history
  • Loading branch information
jr0me committed Aug 8, 2024
1 parent 60d4e6d commit f8bdace
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/agent/communicator/src/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ namespace http_client
{
std::cerr << "Connect failed: " << code.message() << std::endl;
socket.close();
std::this_thread::sleep_for(1000ms);
const auto duration = std::chrono::milliseconds(1000);
timer.expires_after(duration);
co_await timer.async_wait(boost::asio::use_awaitable);
continue;
}

Expand All @@ -116,10 +118,9 @@ namespace http_client
if (ec)
{
socket.close();
break;
}

auto duration = std::chrono::milliseconds(1000);
const auto duration = std::chrono::milliseconds(1000);
timer.expires_after(duration);
co_await timer.async_wait(boost::asio::use_awaitable);
}
Expand Down

0 comments on commit f8bdace

Please sign in to comment.