19 template <
typename T,
typename CompareT>
37 bool IsEmpty() {
return m_attic.empty(); }
42 typedef std::map<SystemPath, RefCountedPtr<T>, CompareT>
CacheMap;
43 typedef std::map<SystemPath, T *, CompareT>
AtticMap;
52 typename CacheMap::const_iterator
Begin()
const {
return m_cache.begin(); }
53 typename CacheMap::const_iterator
End()
const {
return m_cache.end(); }
57 void Erase(
const typename CacheMap::const_iterator &it);
59 bool IsEmpty() {
return m_cache.empty(); }
76 static const unsigned CACHE_JOB_SIZE = 100;
85 class CacheJob :
public Job {
90 virtual void OnFinish();
91 virtual void OnCancel() {}
94 std::unique_ptr<std::vector<SystemPath>> m_paths;
95 std::vector<RefCountedPtr<T>> m_objects;
103 std::set<Slave *> m_slaves;
108 unsigned long long m_cacheHits;
109 unsigned long long m_cacheHitsSlave;
110 unsigned long long m_cacheMisses;
GalaxyObjectCache< Sector, SystemPath::LessSectorOnly > SectorCache
Definition: GalaxyCache.h:113
GalaxyObjectCache< StarSystem, SystemPath::LessSystemOnly > StarSystemCache
Definition: GalaxyCache.h:116
Definition: GalaxyGenerator.h:17
Definition: GalaxyCache.h:46
void Erase(const SystemPath &path)
Definition: GalaxyCache.cpp:147
~Slave()
Definition: GalaxyCache.cpp:156
CacheMap::const_iterator End() const
Definition: GalaxyCache.h:53
RefCountedPtr< T > GetCached(const SystemPath &path)
Definition: GalaxyCache.cpp:127
RefCountedPtr< T > GetIfCached(const SystemPath &path)
Definition: GalaxyCache.cpp:118
void FillCache(const PathVector &paths, CacheFilledCallback callback=CacheFilledCallback())
Definition: GalaxyCache.cpp:181
bool IsEmpty()
Definition: GalaxyCache.h:59
void ClearCache()
Definition: GalaxyCache.cpp:153
CacheMap::const_iterator Begin() const
Definition: GalaxyCache.h:52
Definition: GalaxyCache.h:20
GalaxyObjectCache(Galaxy *galaxy)
Definition: GalaxyCache.h:26
std::function< void()> CacheFilledCallback
Definition: GalaxyCache.h:44
std::map< SystemPath, RefCountedPtr< T >, CompareT > CacheMap
Definition: GalaxyCache.h:42
void OutputCacheStatistics(bool reset=true)
Definition: GalaxyCache.cpp:89
RefCountedPtr< T > GetIfCached(const SystemPath &path)
Definition: GalaxyCache.cpp:42
std::map< SystemPath, T *, CompareT > AtticMap
Definition: GalaxyCache.h:43
RefCountedPtr< Slave > NewSlaveCache()
Definition: GalaxyCache.cpp:97
bool IsEmpty()
Definition: GalaxyCache.h:37
static const std::string CACHE_NAME
Definition: GalaxyCache.h:24
std::vector< SystemPath > PathVector
Definition: GalaxyCache.h:41
~GalaxyObjectCache()
Definition: GalaxyCache.cpp:20
RefCountedPtr< T > GetCached(const SystemPath &path)
Definition: GalaxyCache.cpp:54
void ClearCache()
Definition: GalaxyCache.cpp:82
Definition: JobQueue.h:108
Definition: JobQueue.h:157
Definition: JobQueue.h:33
Definition: RefCounted.h:36
Definition: RefCounted.h:11
Definition: StarSystem.h:27
Definition: SystemPath.h:13