HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_AttributeMap::ScopedLock< Read > Class Template Reference

#include <PDG_AttributeMap.h>

Public Member Functions

 ScopedLock (const PDG_AttributeMap &attribute_map)
 
 ~ScopedLock ()
 

Detailed Description

template<bool Read>
class PDG_AttributeMap::ScopedLock< Read >

Scoped lock of an attribute map and the node that owns the work item associated with the attribute map. This is used to serialize access to work item attributes when running a node callback or adding results from the scheduler.

When a node callback runs, the node's read lock and work item's write lock are acquired. When a full-node callback like onRegenerate is run, the node's write lock is acquired, effectively locking all attribs on all items in the node.

Internally, PDG does not require the use of this lock. The cook logic and dependency graph are structure in such a way that work items don't need to lock in order to safely access themselves or their parent. This lock and the scoped locks around various work item callbacks exist for the benefit of external code that requires direct, random access to PDG work items. PDG attribute events, for example, can safely read attribute data without locking.

Definition at line 201 of file PDG_AttributeMap.h.

Constructor & Destructor Documentation

template<bool Read>
PDG_AttributeMap::ScopedLock< Read >::ScopedLock ( const PDG_AttributeMap attribute_map)
inline

We must always acquire the global lock first, then the attrib lock. Other places in the code such as the onRegenerate callback assume that to be the case, and doing so in the wrong order will cause a deadlock. The global lock is only acquired as a read lock here – acquring a write lock to the global lock can be used to get exclusive access to ALL attribute maps that use the same lock.

Definition at line 210 of file PDG_AttributeMap.h.

template<bool Read>
PDG_AttributeMap::ScopedLock< Read >::~ScopedLock ( )
inline

Definition at line 226 of file PDG_AttributeMap.h.


The documentation for this class was generated from the following file: