mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-16 04:52:37 -04:00
New methods for calculating the count of peers and messages. It should be faster than getting all data in std::list.
Now used in MainWindow.cpp, MessagesDialog.cpp and peerstatus.cpp void p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount); void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox); git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2898 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e5667a915d
commit
84a87fa11b
15 changed files with 99 additions and 61 deletions
|
@ -1523,6 +1523,23 @@ void p3ConnectMgr::getFriendList(std::list<std::string> &peers)
|
|||
//}
|
||||
|
||||
|
||||
void p3ConnectMgr::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount)
|
||||
{
|
||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
if (pnFriendCount) *pnFriendCount = mFriendList.size();
|
||||
if (pnOnlineCount) {
|
||||
*pnOnlineCount = 0;
|
||||
|
||||
std::map<std::string, peerConnectState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++) {
|
||||
if (it->second.state & RS_PEER_S_CONNECTED) {
|
||||
(*pnOnlineCount)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool p3ConnectMgr::connectAttempt(std::string id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue