mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
added cancel in waitToken in rstokenservice
This commit is contained in:
parent
aa05348d55
commit
a02bb0acb6
1 changed files with 5 additions and 3 deletions
|
@ -232,7 +232,8 @@ public:
|
||||||
RsTokenService::GxsRequestStatus waitToken(
|
RsTokenService::GxsRequestStatus waitToken(
|
||||||
uint32_t token,
|
uint32_t token,
|
||||||
std::chrono::milliseconds maxWait = std::chrono::milliseconds(500),
|
std::chrono::milliseconds maxWait = std::chrono::milliseconds(500),
|
||||||
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(2))
|
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(2),
|
||||||
|
bool auto_delete_if_unsuccessful=true)
|
||||||
{
|
{
|
||||||
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
|
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
|
||||||
auto wkStartime = std::chrono::steady_clock::now();
|
auto wkStartime = std::chrono::steady_clock::now();
|
||||||
|
@ -241,12 +242,13 @@ LLwaitTokenBeginLabel:
|
||||||
#endif
|
#endif
|
||||||
auto timeout = std::chrono::steady_clock::now() + maxWait;
|
auto timeout = std::chrono::steady_clock::now() + maxWait;
|
||||||
auto st = requestStatus(token);
|
auto st = requestStatus(token);
|
||||||
while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE)
|
while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE) && std::chrono::steady_clock::now() < timeout )
|
||||||
&& std::chrono::steady_clock::now() < timeout )
|
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(checkEvery);
|
std::this_thread::sleep_for(checkEvery);
|
||||||
st = requestStatus(token);
|
st = requestStatus(token);
|
||||||
}
|
}
|
||||||
|
if(st != RsTokenService::COMPLETE && auto_delete_if_unsuccessful)
|
||||||
|
cancelRequest(token);
|
||||||
|
|
||||||
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
|
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
|
||||||
/* Work around for very slow/old android devices, we don't expect this
|
/* Work around for very slow/old android devices, we don't expect this
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue