HDK
|
#include <instanceRegistry.h>
Public Types | |
typedef HdInstance< VALUE > | InstanceType |
typedef InstanceType::Dictionary::const_iterator | const_iterator |
Public Member Functions | |
HdInstanceRegistry ()=default | |
HdInstanceRegistry (const HdInstanceRegistry &other) | |
InstanceType | GetInstance (typename InstanceType::KeyType const &key) |
Returns a shared instance for given key. More... | |
InstanceType | FindInstance (typename InstanceType::KeyType const &key, bool *found) |
size_t | GarbageCollect (int recycleCount=0) |
template<typename Callback > | |
size_t | GarbageCollect (Callback &&callback, int recycleCount=0) |
const_iterator | begin () const |
const_iterator | end () const |
size_t | size () const |
void | Invalidate () |
HdInstanceRegistry is a dictionary container of HdInstance. This class is almost just a dictionary from key to value. For cleaning unused entries, it provides GarbageCollect() API. It sweeps all entries in the dictionary and erase unreferenced entries. When HdInstance::ValueType is shared_ptr, it is regarded as unreferenced if the shared_ptr is unique (use_count==1). Note that Key is not involved to determine the lifetime of entries.
Definition at line 146 of file instanceRegistry.h.
typedef InstanceType::Dictionary::const_iterator HdInstanceRegistry< VALUE >::const_iterator |
Returns a const iterator being/end of dictionary. Mainly used for resource auditing.
Definition at line 186 of file instanceRegistry.h.
typedef HdInstance<VALUE> HdInstanceRegistry< VALUE >::InstanceType |
Definition at line 148 of file instanceRegistry.h.
|
default |
|
inline |
Copy constructor. Need as HdInstanceRegistry is placed in a map and mutex is not copy constructable, so can't use default
Definition at line 154 of file instanceRegistry.h.
|
inline |
Definition at line 187 of file instanceRegistry.h.
|
inline |
Definition at line 188 of file instanceRegistry.h.
HdInstance< VALUE > HdInstanceRegistry< VALUE >::FindInstance | ( | typename InstanceType::KeyType const & | key, |
bool * | found | ||
) |
Returns a shared instance for a given key only if the key exists in the dictionary.
Definition at line 234 of file instanceRegistry.h.
size_t HdInstanceRegistry< VALUE >::GarbageCollect | ( | int | recycleCount = 0 | ) |
Removes unreferenced entries and returns the count of remaining entries. When recycleCount is greater than zero, unreferenced entries will not be removed until GarbageCollect() is called that many more times, i.e. allowing unreferenced entries to be recycled if they are needed again.
Definition at line 257 of file instanceRegistry.h.
size_t HdInstanceRegistry< VALUE >::GarbageCollect | ( | Callback && | callback, |
int | recycleCount = 0 |
||
) |
Removes unreferenced entries and returns the count of remaining entries. If an entry is to be removed, callback function "callback" will be called on the entry before removal. When recycleCount is greater than zero, unreferenced entries will not be removed until GarbageCollect() is called that many more times, i.e. allowing unreferenced entries to be recycled if they are needed again.
Definition at line 266 of file instanceRegistry.h.
HdInstance< VALUE > HdInstanceRegistry< VALUE >::GetInstance | ( | typename InstanceType::KeyType const & | key | ) |
Returns a shared instance for given key.
Definition at line 211 of file instanceRegistry.h.
void HdInstanceRegistry< VALUE >::Invalidate | ( | ) |
Definition at line 295 of file instanceRegistry.h.
|
inline |
Definition at line 190 of file instanceRegistry.h.