Created
July 23, 2024 23:44
-
-
Save doug65536/cb875825e651b2355b5ae520c1d7a785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::tuple<std::optional<websocket_client::message>, int> | |
websocket_client::recv_until( | |
std::chrono::steady_clock::time_point const& deadline) | |
noexcept | |
{ | |
std::tuple<std::optional< | |
websocket_client::message>, int> result; | |
std::get<1>(result) = recv_until( | |
std::get<0>(result), deadline); | |
return result; | |
} | |
int websocket_client::recv_until( | |
std::optional<websocket_client::message>& result, | |
std::chrono::steady_clock::time_point const& deadline) | |
noexcept | |
{ | |
scoped_lock lock(state_lock); | |
while (stopping || rx_queue.empty()) { | |
if (stopping || cv.wait_until(lock, deadline) == | |
std::cv_status::timeout) | |
{ | |
result = std::nullopt; | |
return ERROR_TIMEOUT; | |
} | |
} | |
result = std::move(rx_queue.front()); | |
rx_queue.pop(); | |
return ERROR_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment