fixed priority problem in async request of group data tht shows up in RsGxsForumThreadWidget

This commit is contained in:
csoler 2020-03-22 23:35:34 +01:00
parent 0f5fd198a4
commit 6616e8a6b3
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 8 additions and 8 deletions

View File

@ -46,6 +46,7 @@ enum class TokenRequestType: uint8_t
MSG_RELATED_INFO = 0x03, MSG_RELATED_INFO = 0x03,
GROUP_STATISTICS = 0x04, GROUP_STATISTICS = 0x04,
SERVICE_STATISTICS = 0x05, SERVICE_STATISTICS = 0x05,
NO_KILL_TYPE = 0x06,
}; };
class RsGxsIfaceHelper class RsGxsIfaceHelper
@ -244,15 +245,14 @@ public:
} }
/// @see RsTokenService::requestGroupInfo /// @see RsTokenService::requestGroupInfo
bool requestGroupInfo( uint32_t& token, const RsTokReqOptions& opts, bool requestGroupInfo( uint32_t& token, const RsTokReqOptions& opts, const std::list<RsGxsGroupId> &groupIds, bool high_priority_request = false )
const std::list<RsGxsGroupId> &groupIds )
{ {
cancelActiveRequestTokens(TokenRequestType::GROUP_INFO); cancelActiveRequestTokens(TokenRequestType::GROUP_INFO);
if( mTokenService.requestGroupInfo(token, 0, opts, groupIds)) if( mTokenService.requestGroupInfo(token, 0, opts, groupIds))
{ {
RS_STACK_MUTEX(mMtx); RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_INFO; mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : (TokenRequestType::GROUP_INFO);
locked_dumpTokens(); locked_dumpTokens();
return true; return true;
} }
@ -261,14 +261,14 @@ public:
} }
/// @see RsTokenService::requestGroupInfo /// @see RsTokenService::requestGroupInfo
bool requestGroupInfo(uint32_t& token, const RsTokReqOptions& opts) bool requestGroupInfo(uint32_t& token, const RsTokReqOptions& opts, bool high_priority_request = false)
{ {
cancelActiveRequestTokens(TokenRequestType::GROUP_INFO); cancelActiveRequestTokens(TokenRequestType::GROUP_INFO);
if( mTokenService.requestGroupInfo(token, 0, opts)) if( mTokenService.requestGroupInfo(token, 0, opts))
{ {
RS_STACK_MUTEX(mMtx); RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_INFO; mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : (TokenRequestType::GROUP_INFO);
locked_dumpTokens(); locked_dumpTokens();
return true; return true;
} }

View File

@ -679,7 +679,7 @@ bool p3GxsForums::getForumsInfo( const std::list<RsGxsGroupId>& forumIds, std::v
} }
else else
{ {
if( !requestGroupInfo(token, opts, forumIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) if( !requestGroupInfo(token, opts, forumIds, forumIds.size()==1) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE )
return false; return false;
} }
return getGroupData(token, forumsInfo); return getGroupData(token, forumsInfo);