HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
subExecutor.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_EXEC_VDF_SUB_EXECUTOR_H
8 #define PXR_EXEC_VDF_SUB_EXECUTOR_H
9 
10 ///\file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/base/tf/mallocTag.h"
15 #include "pxr/base/trace/trace.h"
19 #include "pxr/exec/vdf/request.h"
21 
23 
25 class VdfSchedule;
26 
27 ///////////////////////////////////////////////////////////////////////////////
28 //
29 // \class VdfSubExecutor.
30 //
31 // \brief Executed a VdfNetwork to compute a requested set of value, and uses
32 // cached output values from a parent executor, if unavailable in the
33 // local data manager.
34 //
35 template <
36  template <typename> class EngineType,
37  typename DataManagerType>
39  public VdfDataManagerBasedSubExecutor<DataManagerType, VdfExecutorInterface>
40 {
41  // Base type definition
42  typedef
44  Base;
45 
46  // The speculation executor engine alias declaration, to be bound as a
47  // template template parameter.
48  template <typename T>
49  using SpeculationEngineType =
50  typename EngineType<T>::SpeculationExecutorEngine;
51 
52  // Executor factory.
53  typedef
57  _Factory;
58 
59 public:
60 
61  /// Default constructor
62  ///
64  _engine(*this, &this->_dataManager)
65  { }
66 
67  /// Construct with a parent executor
68  ///
69  explicit VdfSubExecutor(const VdfExecutorInterface *parentExecutor) :
70  Base(parentExecutor),
71  _engine(*this, &this->_dataManager)
72  { }
73 
74  /// Destructor
75  ///
76  virtual ~VdfSubExecutor() {}
77 
78  /// Factory construction.
79  ///
80  virtual const VdfExecutorFactoryBase &GetFactory() const override final {
81  return _factory;
82  }
83 
84 protected:
85 
86  /// Run this executor with the given \p schedule and \p request.
87  ///
88  virtual void _Run(
89  const VdfSchedule &schedule,
90  const VdfRequest &computeRequest,
91  VdfExecutorErrorLogger *errorLogger) override;
92 
93 private:
94 
95  /// Clears the data in the data manager.
96  ///
97  virtual void _ClearData() override;
98 
99  // The factory shared amongst executors of this type.
100  //
101  static const _Factory _factory;
102 
103  // This is the engine that will do most of our hard work for us.
104  //
105  EngineType<DataManagerType> _engine;
106 
107 };
108 
109 ///////////////////////////////////////////////////////////////////////////////
110 
111 template <template <typename> class EngineType, typename DataManagerType>
114 
115 template <template <typename> class EngineType, typename DataManagerType>
116 void
118  const VdfSchedule &schedule,
119  const VdfRequest &computeRequest,
120  VdfExecutorErrorLogger *errorLogger)
121 {
122  // If we have an empty request, bail out.
123  if (computeRequest.IsEmpty()) {
124  return;
125  }
126 
127  TRACE_FUNCTION();
128  TfAutoMallocTag2 tag("Ef", "VdfSubExecutor::Run");
129 
130  _engine.RunSchedule(schedule, computeRequest, errorLogger);
131 }
132 
133 template <template <typename> class EngineType, typename DataManagerType>
134 void
136 {
137  TRACE_FUNCTION();
138 
139  // If the data manager is empty, don't even attempt to clear it.
140  if (!Base::_dataManager.IsEmpty()) {
141  Base::_dataManager.Clear();
142  }
143 
144  Base::InvalidateTopologicalState();
145 }
146 
148 
149 #endif
virtual const VdfExecutorFactoryBase & GetFactory() const overridefinal
Definition: subExecutor.h:80
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
VDF_API bool IsEmpty() const
virtual ~VdfSubExecutor()
Definition: subExecutor.h:76
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:626
Executor used in speculation.
virtual void _Run(const VdfSchedule &schedule, const VdfRequest &computeRequest, VdfExecutorErrorLogger *errorLogger) override
Definition: subExecutor.h:117
Contains a specification of how to execute a particular VdfNetwork.
Definition: schedule.h:40
#define TRACE_FUNCTION()
Definition: trace.h:30
VdfSubExecutor(const VdfExecutorInterface *parentExecutor)
Definition: subExecutor.h:69
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values...