74 if (
_next ==
this)
return 0;
82template<
class T, PtexLruItem T::*item>
100 static const T* dummy = 0;
101 static const std::ptrdiff_t itemOffset = (
const char*)&(dummy->*item) - (
const char*)dummy;
102 return it ? (T*) ((
char*)it - itemOffset) : 0;
225 const char* cp = path;
227 const char* delim = strchr(cp,
':');
232 int len = int(delim-cp);
233 if (len)
_searchdirs.push_back(std::string(cp, len));
247 virtual void purge(
const char* );
249 virtual void getStats(Stats& stats);
Contains PtexHashMap, a lightweight multi-threaded hash table.
#define PTEX_NAMESPACE_END
File-handle and memory cache for reading ptex files.
size_t _memUsedAccountedFor
size_t _opensAccountedFor
bool tryPurge(size_t &memUsedChange)
size_t getMemUsedChange()
PtexCachedReader(bool premultiply, PtexInputHandler *inputHandler, PtexErrorHandler *errorHandler, PtexReaderCache *cache)
bool tryPrune(size_t &memUsedChange)
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
PtexLruItem _activeFilesItem
size_t _blockReadsAccountedFor
PtexLruItem _openFilesItem
size_t getBlockReadsChange()
volatile int32_t _refCount
Custom handler interface redirecting Ptex error messages.
void push(PtexLruItem *item)
Cache for reading Ptex texture files.
PtexLruList< PtexCachedReader, &PtexCachedReader::_activeFilesItem > _activeFiles
void adjustFilesOpen(size_t amount)
void logRecentlyUsed(PtexCachedReader *reader)
MruList *volatile _prevMruList
void adjustMemUsed(size_t amount)
virtual void release()
Release PtexCache. Cache will be immediately destroyed and all resources will be released.
virtual void setSearchPath(const char *path)
Set a search path for finding textures.
virtual const char * getSearchPath()
Query the search path.
virtual PtexTexture * get(const char *path, Ptex::String &error)
Access a texture.
bool findFile(const char *&filename, std::string &buffer, Ptex::String &error)
virtual void getStats(Stats &stats)
Get stats.
PtexReaderCache(int maxFiles, size_t maxMem, bool premultiply, PtexInputHandler *inputHandler, PtexErrorHandler *errorHandler)
static const int numMruFiles
PtexLruList< PtexCachedReader, &PtexCachedReader::_openFilesItem > _openFiles
PtexHashMap< StringKey, PtexCachedReader * > FileMap
virtual void purgeAll()
Remove all texture files from the cache.
volatile size_t _filesOpen
MruList *volatile _mruList
virtual void purge(PtexTexture *)
Remove a texture file from the cache.
std::vector< std::string > _searchdirs
volatile size_t _blockReads
Interface for reading data from a ptex file.
PtexCachedReader *volatile files[numMruFiles]
void operator()(PtexCachedReader *reader)
size_t memUsedChangeTotal