MAINT-5575: Begin conversion to Singleton<> for Experience Cache. Commited on branch so that I don't trigger a build of it until I'm ready.
--HG-- branch : MAINT-5575master
parent
02c3262ac8
commit
99e56eedab
File diff suppressed because it is too large
Load Diff
|
|
@ -30,15 +30,47 @@
|
|||
#define LL_LLEXPERIENCECACHE_H
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llsingleton.h"
|
||||
#include "llsd.h"
|
||||
#include <boost/signals2.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
class LLSD;
|
||||
class LLUUID;
|
||||
|
||||
|
||||
|
||||
namespace LLExperienceCache
|
||||
class LLExperienceCache: public LLSingleton < LLExperienceCache >
|
||||
{
|
||||
friend class LLSingleton < LLExperienceCache > ;
|
||||
|
||||
public:
|
||||
typedef boost::function<void(const LLSD &)> Callback_t;
|
||||
|
||||
void erase(const LLUUID& key);
|
||||
bool fetch(const LLUUID& key, bool refresh = false);
|
||||
void insert(const LLSD& experience_data);
|
||||
const LLSD& get(const LLUUID& key);
|
||||
|
||||
// If name information is in cache, callback will be called immediately.
|
||||
void get(const LLUUID& key, Callback_t slot);
|
||||
|
||||
private:
|
||||
// Callback types for get()
|
||||
// typedef boost::signals2::signal < void(const LLSD &) > callback_signal_t;
|
||||
typedef boost::signals2::signal < Callback_t > callback_signal_t;
|
||||
typedef std::map<LLUUID, LLSD> cache_t;
|
||||
|
||||
//--------------------------------------------
|
||||
LLExperienceCache();
|
||||
virtual ~LLExperienceCache();
|
||||
|
||||
void exportFile(std::ostream& ostr) const;
|
||||
void importFile(std::istream& istr);
|
||||
|
||||
//--------------------------------------------
|
||||
void processExperience(const LLUUID& public_key, const LLSD& experience);
|
||||
|
||||
|
||||
const std::string PRIVATE_KEY = "private_id";
|
||||
const std::string MISSING = "DoesNotExist";
|
||||
|
||||
|
|
@ -61,19 +93,12 @@ namespace LLExperienceCache
|
|||
const int PROPERTY_GRID = 1 << 4;
|
||||
const int PROPERTY_PRIVATE = 1 << 5;
|
||||
const int PROPERTY_DISABLED = 1 << 6;
|
||||
const int PROPERTY_SUSPENDED = 1 << 7;
|
||||
|
||||
const int PROPERTY_SUSPENDED = 1 << 7;
|
||||
|
||||
// default values
|
||||
const static F64 DEFAULT_EXPIRATION = 600.0;
|
||||
const static S32 DEFAULT_QUOTA = 128; // this is megabytes
|
||||
|
||||
// Callback types for get() below
|
||||
typedef boost::signals2::signal<void (const LLSD& experience)>
|
||||
callback_signal_t;
|
||||
typedef callback_signal_t::slot_type callback_slot_t;
|
||||
typedef std::map<LLUUID, LLSD> cache_t;
|
||||
|
||||
|
||||
void setLookupURL(const std::string& lookup_url);
|
||||
bool hasLookupURL();
|
||||
|
|
@ -81,24 +106,26 @@ namespace LLExperienceCache
|
|||
void setMaximumLookups(int maximumLookups);
|
||||
|
||||
void idle();
|
||||
void exportFile(std::ostream& ostr);
|
||||
void importFile(std::istream& istr);
|
||||
void initClass();
|
||||
void bootstrap(const LLSD& legacyKeys, int initialExpiration);
|
||||
|
||||
void erase(const LLUUID& key);
|
||||
bool fetch(const LLUUID& key, bool refresh=false);
|
||||
void insert(const LLSD& experience_data);
|
||||
const LLSD& get(const LLUUID& key);
|
||||
|
||||
// If name information is in cache, callback will be called immediately.
|
||||
void get(const LLUUID& key, callback_slot_t slot);
|
||||
|
||||
const cache_t& getCached();
|
||||
|
||||
// maps an experience private key to the experience id
|
||||
LLUUID getExperienceId(const LLUUID& private_key, bool null_if_not_found=false);
|
||||
|
||||
//=====================================================================
|
||||
inline friend std::ostream &operator << (std::ostream &os, const LLExperienceCache &cache)
|
||||
{
|
||||
cache.exportFile(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
inline friend std::istream &operator >> (std::istream &is, LLExperienceCache &cache)
|
||||
{
|
||||
cache.importFile(is);
|
||||
return is;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // LL_LLEXPERIENCECACHE_H
|
||||
|
|
|
|||
|
|
@ -2820,9 +2820,10 @@ void LLStartUp::initNameCache()
|
|||
|
||||
|
||||
void LLStartUp::initExperiences()
|
||||
{
|
||||
{
|
||||
// just a get instance here. Should trigger loading the cache.
|
||||
LLExperienceCache::getInstance();
|
||||
LLAppViewer::instance()->loadExperienceCache();
|
||||
LLExperienceCache::initClass();
|
||||
LLExperienceLog::instance().initialize();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue