mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
attempt to solve GXS data access problems in new blocking API
This commit is contained in:
parent
1f0678075f
commit
ab2c1f23e9
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user