11 #ifndef __UT_CappedCache__
12 #define __UT_CappedCache__
38 virtual unsigned int getHash()
const = 0;
63 virtual int64 getMemoryUsage()
const = 0;
112 {
return myMemUsage; }
114 {
return myMaxUsage; }
153 template <
typename T>
157 ut_CappedBin *curr=myHead;
160 for (
exint i = 0; i <
n; ++i, curr = next)
163 if (!task(curr->getKey(), curr->getItem()))
187 exint getTimeStamp()
const {
return myTimeStamp; }
188 void setTimeStamp(
exint t) { myTimeStamp =
t; }
192 return head - myTimeStamp <= watermark;
198 ut_CappedBin *myPrev;
199 ut_CappedBin *myNext;
203 class ut_cappedKeyCompare
207 {
return (
size_t)a->
getHash(); }
213 ut_cappedKeyCompare> ut_CappedMap;
219 void addItem(ut_CappedBin *bin);
220 void accessItem(ut_CappedBin *bin);
221 void removeAndDeleteItem(ut_CappedBin *bin);
222 void insertItem(ut_CappedBin *bin);
223 void unlinkItem(ut_CappedBin *bin);
230 ut_CappedBin *
volatile myHead;
231 volatile int64 myMemUsage;
234 exint myQuarterEntries;
exint entries() const
Number of entries in the cache.
UT_RecursiveSpinLock UT_CappedLock
UT_StringArray JOINTS head
int64 utGetMaxSize() const override
Base class for search keys for UT_CappedCache.
virtual bool isEqual(const UT_CappedKey &key) const =0
Test equality.
GLboolean GLboolean GLboolean GLboolean a
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
A reference counter base class for use with UT_IntrusivePtr.
UT_IntrusiveRefCounter & operator=(const UT_IntrusiveRefCounter &) noexcept
Assignment operator: Does not modify counter.
virtual int64 utReduceCacheSizeBy(int64 amount)=0
void threadSafeTraversal(T &task)
virtual unsigned int getHash() const =0
Return a hash for the key.
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
Common base class for various caches.
#define UT_ConcurrentHashMap
bool utHasMaxSize() const override
virtual void utSetMaxSize(int64)
const char * utGetCacheName() const override
exint getListEntries() const
Base class for items in the UT_CappedCache.
int64 utGetCurrentSize() const override
UT_Cache & operator=(const UT_Cache &)=delete