Reduced locking time of mutex in RsGenExchange::processMsgMetaChanges and RsGenExchange::processGrpMetaChanges.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8005 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-03-08 23:12:57 +00:00
parent 58430d0a9d
commit f6a1cbb3b2

View File

@ -1634,14 +1634,22 @@ void RsGenExchange::setMsgServiceString(uint32_t& token, const RsGxsGrpMsgIdPair
void RsGenExchange::processMsgMetaChanges()
{
RS_STACK_MUTEX(mGenMtx) ;
std::map<uint32_t, MsgLocMetaData> metaMap;
{
RS_STACK_MUTEX(mGenMtx);
if (mMsgLocMetaMap.empty())
{
return;
}
metaMap = mMsgLocMetaMap;
mMsgLocMetaMap.clear();
}
GxsMsgReq msgIds;
std::map<uint32_t, MsgLocMetaData>::iterator mit = mMsgLocMetaMap.begin(),
mit_end = mMsgLocMetaMap.end();
for(; mit != mit_end; ++mit)
std::map<uint32_t, MsgLocMetaData>::iterator mit;
for (mit = metaMap.begin(); mit != metaMap.end(); ++mit)
{
MsgLocMetaData& m = mit->second;
@ -1696,28 +1704,39 @@ void RsGenExchange::processMsgMetaChanges()
{
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
}
mMsgNotify.insert(std::make_pair(token, m.msgId));
{
RS_STACK_MUTEX(mGenMtx);
mMsgNotify.insert(std::make_pair(token, m.msgId));
}
}
if (!msgIds.empty()) {
RS_STACK_MUTEX(mGenMtx);
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true);
c->msgChangeMap = msgIds;
mNotifications.push_back(c);
}
mMsgLocMetaMap.clear();
}
void RsGenExchange::processGrpMetaChanges()
{
RS_STACK_MUTEX(mGenMtx) ;
std::map<uint32_t, GrpLocMetaData > metaMap;
{
RS_STACK_MUTEX(mGenMtx);
if (mGrpLocMetaMap.empty())
{
return;
}
metaMap = mGrpLocMetaMap;
mGrpLocMetaMap.clear();
}
std::list<RsGxsGroupId> grpChanged;
std::map<uint32_t, GrpLocMetaData>::iterator mit = mGrpLocMetaMap.begin(),
mit_end = mGrpLocMetaMap.end();
for(; mit != mit_end; ++mit)
std::map<uint32_t, GrpLocMetaData>::iterator mit;
for (mit = metaMap.begin(); mit != metaMap.end(); ++mit)
{
GrpLocMetaData& g = mit->second;
uint32_t token = mit->first;
@ -1735,17 +1754,20 @@ void RsGenExchange::processGrpMetaChanges()
{
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
}
mGrpNotify.insert(std::make_pair(token, g.grpId));
{
RS_STACK_MUTEX(mGenMtx);
mGrpNotify.insert(std::make_pair(token, g.grpId));
}
}
if(!grpChanged.empty())
{
RS_STACK_MUTEX(mGenMtx);
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, true);
gc->mGrpIdList = grpChanged;
mNotifications.push_back(gc);
}
mGrpLocMetaMap.clear();
}
bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpCv)