HDK
|
#include <instanceRegistry.h>
Classes | |
struct | ValueHolder |
Public Types | |
typedef uint64_t | KeyType |
typedef VALUE | ValueType |
typedef KeyType | ID |
typedef tbb::concurrent_unordered_map < KeyType, ValueHolder > | Dictionary |
typedef std::mutex | RegistryMutex |
typedef std::unique_lock < RegistryMutex > | RegistryLock |
Public Member Functions | |
HdInstance ()=delete | |
HdInstance (KeyType const &key, ValueType const &value, RegistryLock &®istryLock, Dictionary *container) | |
HdInstance (KeyType const &key) | |
KeyType const & | GetKey () const |
Returns the key. More... | |
ValueType const & | GetValue () const |
Returns the value. More... | |
void | SetValue (ValueType const &value) |
Update the value in dictionary indexed by the key. More... | |
bool | IsFirstInstance () const |
Returns true if the value has not been initialized. More... | |
This class is used as an interface to a shared instance in HdInstanceRegistry.
KeyType is a hashable index type and VALUE is shared_ptr. In most use cases, the client computes a hash key which represents large bulky data (like topology, primvars) and registers it into HdInstanceRegistry. If the key has already been registered, the registry returns HdInstance and the client can use GetValue() without setting/computing actual bulky data. If it doesn't exist, IsFirstInstance() returns true for the first instance and the client needs to populate an appropriate data VALUE into the instance by SetValue().
In order to support concurrent access to HdInstanceRegistry, this class holds a lock to a mutex in HdInstanceRegistry. This lock will be held until the instance of this interface class is destroyed.
Definition at line 60 of file instanceRegistry.h.
typedef tbb::concurrent_unordered_map<KeyType, ValueHolder> HdInstance< VALUE >::Dictionary |
Definition at line 79 of file instanceRegistry.h.
typedef KeyType HdInstance< VALUE >::ID |
Definition at line 65 of file instanceRegistry.h.
typedef uint64_t HdInstance< VALUE >::KeyType |
Definition at line 62 of file instanceRegistry.h.
typedef std::unique_lock<RegistryMutex> HdInstance< VALUE >::RegistryLock |
Definition at line 82 of file instanceRegistry.h.
typedef std::mutex HdInstance< VALUE >::RegistryMutex |
Definition at line 81 of file instanceRegistry.h.
typedef VALUE HdInstance< VALUE >::ValueType |
Definition at line 63 of file instanceRegistry.h.
|
delete |
|
inlineexplicit |
Construct an instance holding a registry lock, representing a value held in a registry container.
Definition at line 88 of file instanceRegistry.h.
|
inlineexplicit |
Construct an instance with no lock or registry container. This is used to present a consistent interface to clients in cases where shared resource registration is disabled.
Definition at line 102 of file instanceRegistry.h.
|
inline |
Returns the key.
Definition at line 111 of file instanceRegistry.h.
|
inline |
Returns the value.
Definition at line 114 of file instanceRegistry.h.
|
inline |
Returns true if the value has not been initialized.
Definition at line 123 of file instanceRegistry.h.
|
inline |
Update the value in dictionary indexed by the key.
Definition at line 117 of file instanceRegistry.h.