attempt to solve GXS data access problems in new blocking API

This commit is contained in:
csoler 2020-03-07 20:39:10 +01:00
parent 1f0678075f
commit ab2c1f23e9
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 18 additions and 8 deletions

View File

@ -274,8 +274,7 @@ struct RsGxsIfaceHelper
{ mTokenService.requestGroupStatistic(token, grpId); }
/// @see RsTokenService::cancelRequest
bool cancelRequest(uint32_t token)
{ return mTokenService.cancelRequest(token); }
bool cancelRequest(uint32_t token) { return mTokenService.cancelRequest(token); }
/**
* @deprecated
@ -291,12 +290,21 @@ protected:
* @param[in] token token associated to the request caller is waiting for
* @param[in] maxWait maximum waiting time in milliseconds
* @param[in] checkEvery time in millisecond between status checks
* @param[in] auto_delete_if_unsuccessful delete the request when it fails. This avoid leaving useless pending requests in the queue that would slow down additional calls.
*/
RsTokenService::GxsRequestStatus waitToken(
uint32_t token,
std::chrono::milliseconds maxWait = std::chrono::milliseconds(2000),
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(20))
{ return mTokenService.waitToken(token, maxWait, checkEvery); }
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(20),
bool auto_delete_if_unsuccessful=true)
{
RsTokenService::GxsRequestStatus res = mTokenService.waitToken(token, maxWait, checkEvery);
if(res != RsTokenService::COMPLETE && auto_delete_if_unsuccessful)
cancelRequest(token);
return res;
}
private:
RsGxsIface& mGxs;

View File

@ -278,8 +278,9 @@ bool p3GxsCircles::getCirclesSummaries(std::list<RsGroupMetaData>& circles)
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token, opts)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
cancelRequest(token);
return getGroupSummary(token, circles);
}
@ -289,8 +290,9 @@ bool p3GxsCircles::getCirclesInfo( const std::list<RsGxsGroupId>& circlesIds,
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, circlesIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
if( !requestGroupInfo(token, opts, circlesIds) || waitToken(token) != RsTokenService::COMPLETE )
return false;
return getGroupData(token, circlesInfo);
}