27 #include "precompiled.h"
101 const size_t alignedSize = Align<maxSectorSize>(size);
105 return DummySharedPtr<u8>(0);
117 const size_t alignedSize = Align<maxSectorSize>(size);
183 shared_ptr<u8> discardedData;
size_t discardedSize;
189 return shared_ptr<u8>();
194 void Add(
const VfsPath& pathname,
const shared_ptr<u8>& data,
size_t size,
size_t cost)
231 : impl(new
Impl(size))
237 return impl->Reserve(size);
242 impl->Add(pathname, data, size, cost);
247 impl->Remove(pathname);
252 return impl->Retrieve(pathname, data, size);
bool retrieve(const Key &key, Item &item, size_t *psize=0, bool refill_credit=true)
shared_ptr< Allocator > PAllocator
int mprotect(void *addr, size_t len, int prot)
shared_ptr< u8 > Reserve(size_t size)
bool remove_least_valuable(Item *pItem=0, size_t *pSize=0)
bool Retrieve(const VfsPath &pathname, shared_ptr< u8 > &data, size_t &size)
Attempt to retrieve a file's contents from the file cache.
void operator()(u8 *mem) const
void add(const Key &key, const Item &item, size_t size, size_t cost)
void Deallocate(u8 *mem, size_t size)
void remove(const Key &key)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
bool Retrieve(const VfsPath &pathname, shared_ptr< u8 > &data, size_t &size)
AllocatorChecker m_checker
void OnAllocate(void *p, size_t size)
Allocator(size_t maxSize)
void Remove(const VfsPath &pathname)
Remove a file's contents from the cache (if it exists).
HeaderlessAllocator m_allocator
shared_ptr< u8 > Reserve(size_t size)
Reserve a chunk of the cache's memory region.
Cache< VfsPath, shared_ptr< u8 > > CacheType
void OnDeallocate(void *p, size_t size)
void Remove(const VfsPath &pathname)
shared_ptr< u8 > Allocate(size_t size, const PAllocator &pthis)
void Add(const VfsPath &pathname, const shared_ptr< u8 > &data, size_t size, size_t cost=1)
Add a file's contents to the cache.
FileCacheDeleter(size_t size, const PAllocator &allocator)
#define stats_buf_alloc(size, alignedSize)
void Add(const VfsPath &pathname, const shared_ptr< u8 > &data, size_t size, size_t cost)