mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-28 08:07:31 -04:00
attempt to solve GXS data access problems in new blocking API
This commit is contained in:
parent
1f0678075f
commit
ab2c1f23e9
2 changed files with 18 additions and 8 deletions
|
@ -274,8 +274,7 @@ struct RsGxsIfaceHelper
|
||||||
{ mTokenService.requestGroupStatistic(token, grpId); }
|
{ mTokenService.requestGroupStatistic(token, grpId); }
|
||||||
|
|
||||||
/// @see RsTokenService::cancelRequest
|
/// @see RsTokenService::cancelRequest
|
||||||
bool cancelRequest(uint32_t token)
|
bool cancelRequest(uint32_t token) { return mTokenService.cancelRequest(token); }
|
||||||
{ return mTokenService.cancelRequest(token); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
@ -291,12 +290,21 @@ protected:
|
||||||
* @param[in] token token associated to the request caller is waiting for
|
* @param[in] token token associated to the request caller is waiting for
|
||||||
* @param[in] maxWait maximum waiting time in milliseconds
|
* @param[in] maxWait maximum waiting time in milliseconds
|
||||||
* @param[in] checkEvery time in millisecond between status checks
|
* @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(
|
RsTokenService::GxsRequestStatus waitToken(
|
||||||
uint32_t token,
|
uint32_t token,
|
||||||
std::chrono::milliseconds maxWait = std::chrono::milliseconds(2000),
|
std::chrono::milliseconds maxWait = std::chrono::milliseconds(2000),
|
||||||
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(20))
|
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(20),
|
||||||
{ return mTokenService.waitToken(token, maxWait, checkEvery); }
|
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:
|
private:
|
||||||
RsGxsIface& mGxs;
|
RsGxsIface& mGxs;
|
||||||
|
|
|
@ -278,8 +278,9 @@ bool p3GxsCircles::getCirclesSummaries(std::list<RsGroupMetaData>& circles)
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||||
if( !requestGroupInfo(token, opts)
|
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
|
||||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
cancelRequest(token);
|
||||||
|
|
||||||
return getGroupSummary(token, circles);
|
return getGroupSummary(token, circles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,8 +290,9 @@ bool p3GxsCircles::getCirclesInfo( const std::list<RsGxsGroupId>& circlesIds,
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
if( !requestGroupInfo(token, opts, circlesIds)
|
if( !requestGroupInfo(token, opts, circlesIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
return false;
|
||||||
|
|
||||||
return getGroupData(token, circlesInfo);
|
return getGroupData(token, circlesInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue