mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
cleaned-up circles cache. Needs testing.
This commit is contained in:
parent
65fa29e789
commit
11a4b6540f
3 changed files with 880 additions and 879 deletions
File diff suppressed because it is too large
Load diff
|
@ -130,9 +130,9 @@ public:
|
||||||
|
|
||||||
class RsGxsCircleCache
|
class RsGxsCircleCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsCircleCache();
|
RsGxsCircleCache();
|
||||||
|
|
||||||
bool loadBaseCircle(const RsGxsCircleGroup &circle);
|
bool loadBaseCircle(const RsGxsCircleGroup &circle);
|
||||||
bool loadSubCircle(const RsGxsCircleCache &subcircle);
|
bool loadSubCircle(const RsGxsCircleCache &subcircle);
|
||||||
|
|
||||||
|
@ -142,6 +142,24 @@ class RsGxsCircleCache
|
||||||
bool addAllowedPeer(const RsPgpId &pgpid);
|
bool addAllowedPeer(const RsPgpId &pgpid);
|
||||||
bool addLocalFriend(const RsPgpId &pgpid);
|
bool addLocalFriend(const RsPgpId &pgpid);
|
||||||
|
|
||||||
|
// Cache related data
|
||||||
|
|
||||||
|
enum CircleEntryCacheStatus: uint8_t // This enum
|
||||||
|
{
|
||||||
|
UNKNOWN = 0x00, // Used to detect uninitialized memory
|
||||||
|
NO_DATA = 0x01, // Used in the constuctor
|
||||||
|
LOADING = 0x02, // When the token request to load cache has been sent and no data is present
|
||||||
|
UPDATING = 0x03, // Starting from this level the cache entry can be used
|
||||||
|
CHECKING_MEMBERSHIP = 0x04, // Means we're actually looking into msgs to update membership status
|
||||||
|
UP_TO_DATE = 0x05, // Everything should be loaded here.
|
||||||
|
};
|
||||||
|
rstime_t mLastUpdatedMembershipTS ; // Last time the subscribe messages have been requested. Should be reset when new messages arrive.
|
||||||
|
rstime_t mLastUpdateTime; // Last time the cache entry was loaded
|
||||||
|
CircleEntryCacheStatus mStatus; // Overall state of the cache entry
|
||||||
|
bool mAllIdsHere ; // True when all ids are knwon and available.
|
||||||
|
|
||||||
|
// GxsCircle related data
|
||||||
|
|
||||||
RsGxsCircleId mCircleId;
|
RsGxsCircleId mCircleId;
|
||||||
std::string mCircleName;
|
std::string mCircleName;
|
||||||
|
|
||||||
|
@ -152,13 +170,11 @@ class RsGxsCircleCache
|
||||||
uint32_t mGroupStatus;
|
uint32_t mGroupStatus;
|
||||||
uint32_t mGroupSubscribeFlags;
|
uint32_t mGroupSubscribeFlags;
|
||||||
|
|
||||||
rstime_t mUpdateTime;
|
|
||||||
#ifdef SUBSCIRCLES
|
#ifdef SUBSCIRCLES
|
||||||
std::set<RsGxsCircleId> mUnprocessedCircles;
|
std::set<RsGxsCircleId> mUnprocessedCircles;
|
||||||
std::set<RsGxsCircleId> mProcessedCircles;
|
std::set<RsGxsCircleId> mProcessedCircles;
|
||||||
#endif
|
#endif
|
||||||
std::map<RsGxsId,RsGxsCircleMembershipStatus> mMembershipStatus;
|
std::map<RsGxsId,RsGxsCircleMembershipStatus> mMembershipStatus;
|
||||||
rstime_t mLastUpdatedMembershipTS ; // last time the subscribe messages have been requested. Should be reset when new messages arrive.
|
|
||||||
|
|
||||||
std::set<RsGxsId> mAllowedGxsIds; // IDs that are allowed in the circle and have requested membership. This is the official members list.
|
std::set<RsGxsId> mAllowedGxsIds; // IDs that are allowed in the circle and have requested membership. This is the official members list.
|
||||||
std::set<RsPgpId> mAllowedNodes;
|
std::set<RsPgpId> mAllowedNodes;
|
||||||
|
@ -319,20 +335,17 @@ public:
|
||||||
std::list<RsGxsCircleId> mCirclePersonalIdList;
|
std::list<RsGxsCircleId> mCirclePersonalIdList;
|
||||||
|
|
||||||
/***** Caching Circle Info, *****/
|
/***** Caching Circle Info, *****/
|
||||||
// initial load queue
|
|
||||||
std::list<RsGxsCircleId> mCacheLoad_ToCache;
|
|
||||||
|
|
||||||
// waiting for subcircle to load. (first is part of each of the second list)
|
// waiting for subcircle to load. (first is part of each of the second list)
|
||||||
// TODO.
|
// TODO.
|
||||||
//std::map<RsGxsCircleId, std::list<RsGxsCircleId> > mCacheLoad_SubCircle;
|
//std::map<RsGxsCircleId, std::list<RsGxsCircleId> > mCacheLoad_SubCircle;
|
||||||
|
|
||||||
// Circles that are being loaded.
|
std::set<RsGxsCircleId> mCirclesToLoad; // list of circles to update/load, so that we can treat them by groups.
|
||||||
std::map<RsGxsCircleId, RsGxsCircleCache> mLoadingCache;
|
RsMemCache<RsGxsCircleId, RsGxsCircleCache> mCircleCache; // actual cache data
|
||||||
|
|
||||||
// actual cache.
|
void debug_dumpCache(); // debug method to overview what's going on
|
||||||
RsMemCache<RsGxsCircleId, RsGxsCircleCache> mCircleCache;
|
bool debug_dumpCacheEntry(RsGxsCircleCache &cache);
|
||||||
|
private:
|
||||||
private:
|
|
||||||
|
|
||||||
std::string genRandomId();
|
std::string genRandomId();
|
||||||
|
|
||||||
|
@ -347,6 +360,7 @@ public:
|
||||||
std::list<RsGxsId> mDummyOwnIds;
|
std::list<RsGxsId> mDummyOwnIds;
|
||||||
bool mCacheUpdated ;
|
bool mCacheUpdated ;
|
||||||
rstime_t mLastCacheUpdateEvent;
|
rstime_t mLastCacheUpdateEvent;
|
||||||
|
rstime_t mLastDebugPrintTS;
|
||||||
|
|
||||||
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,7 +60,12 @@ public:
|
||||||
|
|
||||||
bool is_cached(const Key &key) const;
|
bool is_cached(const Key &key) const;
|
||||||
bool fetch(const Key &key, Value &data);
|
bool fetch(const Key &key, Value &data);
|
||||||
Value &ref(const Key &key); // like map[] installs empty one if non-existent.
|
|
||||||
|
// Like map[] installs empty one if non-existent.
|
||||||
|
|
||||||
|
Value& ref(const Key &key);
|
||||||
|
Value& operator[](const Key& key) { return ref(key); }
|
||||||
|
|
||||||
bool store(const Key &key, const Value &data);
|
bool store(const Key &key, const Value &data);
|
||||||
bool erase(const Key &key); // clean up cache.
|
bool erase(const Key &key); // clean up cache.
|
||||||
|
|
||||||
|
@ -71,6 +76,7 @@ public:
|
||||||
template<class ClientClass> bool applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(Value&));
|
template<class ClientClass> bool applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(Value&));
|
||||||
|
|
||||||
uint32_t size() const { return mDataMap.size() ; }
|
uint32_t size() const { return mDataMap.size() ; }
|
||||||
|
void printStats(std::ostream& out);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts);
|
bool update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts);
|
||||||
|
@ -96,7 +102,6 @@ private:
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
// some statistics.
|
// some statistics.
|
||||||
void printStats(std::ostream &out);
|
|
||||||
void clearStats();
|
void clearStats();
|
||||||
|
|
||||||
mutable uint32_t mStats_inserted;
|
mutable uint32_t mStats_inserted;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue