added cancel in waitToken in rstokenservice

This commit is contained in:
csoler 2020-03-11 22:41:57 +01:00
parent aa05348d55
commit a02bb0acb6
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C

View File

@ -232,7 +232,8 @@ public:
RsTokenService::GxsRequestStatus waitToken(
uint32_t token,
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)
auto wkStartime = std::chrono::steady_clock::now();
@ -241,12 +242,13 @@ LLwaitTokenBeginLabel:
#endif
auto timeout = std::chrono::steady_clock::now() + maxWait;
auto st = requestStatus(token);
while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE)
&& std::chrono::steady_clock::now() < timeout )
while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE) && std::chrono::steady_clock::now() < timeout )
{
std::this_thread::sleep_for(checkEvery);
st = requestStatus(token);
}
if(st != RsTokenService::COMPLETE && auto_delete_if_unsuccessful)
cancelRequest(token);
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
/* Work around for very slow/old android devices, we don't expect this