HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGE_PropagateGroup.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __PDGE_PROPAGATE_GROUP_H__
10 #define __PDGE_PROPAGATE_GROUP_H__
11 
12 #include "PDGE_API.h"
13 
14 #include "PDGE_Dependency.h"
15 #include "PDGE_DependencyOwner.h"
16 
17 #include <UT/UT_Array.h>
18 #include <UT/UT_ArrayMap.h>
19 #include <UT/UT_NonCopyable.h>
20 #include <UT/UT_TBBSpinLock.h>
21 
22 /*
23  * Provides a mechanism for a dependency owner to wait for all descendants
24  * from a given upstream dependency, without knowing what they are ahead of
25  * time. For example, this is used for targeted partitioning features and
26  * feedback loops in $PDG.
27  */
29 {
30 public:
31  /// Constructs a new propagate group with the specified owner. The owner
32  /// is used to when connecting this group to input groups and adding
33  /// entries that should only propagate to a certain depth or target node.
35  virtual ~PDGE_PropagateGroup();
36 
37  /// Returns the total memory usage of this propagate groiup
38  int64 getMemoryUsage(bool inclusive) const;
39 
40  /// Adds a target owner to the set of targets associated with this group.
41  /// These are the owners that the group may target, and the group will not
42  /// recurse beyond them when adding dependencies.
44  { myTargetOwners.insert(target); }
45 
46  /// Adds an input group to this propagate group. Dependencies are added
47  /// on input group entries, and propagate back down to this group during
48  /// evaluation.
49  inline void addInputGroup(PDGE_PropagateGroup* input_group)
50  { myInputGroups.append(input_group); }
51 
52  /// Resets the propagate group. This will free all owned dependencies and
53  /// clear all structures including input groups and targets.
54  void reset(PDGE_Dependency* extra_dependency);
55 
56  /// Adds an propagation entry to this group. The entry must have a target
57  /// owner and a root dependency. Optionally, an additional dependent can
58  /// be passed that will automatically be made to depend on the new entry.
59  ///
60  /// The root is the source dependency for which the entry is associated
61  /// with. The entry will wait for the root and all of its descendants
62  /// between the target owner and this group.
63  void addEntry(
65  PDGE_Dependency* root,
66  PDGE_Dependency* dependent);
67 
68  /// Copies relevant propagate depenencies from source onto the specified
69  /// downstream dependent, based on what propagate entries exist in this map.
70  void propagateDependencies(
72  PDGE_Dependency* destination);
73 
74  /// Returns the list of dependency owners for a propagate dependency owned
75  /// by this group.
76  void upstreamOwners(
78  PDGE_Dependency* dependency) const;
79 
80  /// Returns the root owner for a propagate dependency owned by this group
81  PDGE_DependencyOwner* rootOwner(PDGE_Dependency* dependent) const;
82 
83 private:
86 
87  void propagateInternal(PDGE_Dependency* source,
88  PDGE_Dependency* destination);
89  PDGE_Dependency* addEntryInternal(
91  const PDGE_DependencyOwner::Set& targets,
92  PDGE_Dependency* root,
93  PDGE_Dependency* dependent);
94  PDGE_Dependency* addEntryInternal(
95  PDGE_Dependency* root);
96 private:
97  Array myInputGroups;
98  Map myPropagateDependencies;
99  Map myDependents;
100  PDGE_DependencyOwner::Set myTargetOwners;
101  PDGE_DependencyOwner* myOwner;
102  PDGE_Dependency* myExtraDependency;
103  mutable UT_TBBSpinLock myLock;
104 };
105 
106 #endif
Definition: ImfArray.h:45
GLboolean reset
Definition: glad.h:5138
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
long long int64
Definition: SYS_Types.h:116
GLenum target
Definition: glcorearb.h:1667
#define PDGE_API
Definition: PDGE_API.h:23
void addInputGroup(PDGE_PropagateGroup *input_group)
void addTarget(PDGE_DependencyOwner *target)