Loading...
Searching...
No Matches
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_EF_SUB_EXECUTOR_H
8#define PXR_EXEC_EF_SUB_EXECUTOR_H
9
11
12#include "pxr/pxr.h"
13
21
22PXR_NAMESPACE_OPEN_SCOPE
23
25class VdfSchedule;
26
28//
29// \class EfSubExecutor.
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//
35template <
36 template <typename> class EngineType,
37 typename DataManagerType>
38class EfSubExecutor :
39 public VdfDataManagerBasedSubExecutor<DataManagerType, VdfExecutorInterface>
40{
41 // Base type definition
42 typedef
43 VdfDataManagerBasedSubExecutor<DataManagerType, VdfExecutorInterface>
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
54 VdfExecutorFactory<
55 EfSubExecutor<EngineType, DataManagerType>,
57 _Factory;
58
59public:
60
63 EfSubExecutor() :
64 _engine(*this, &this->_dataManager)
65 { }
66
69 explicit EfSubExecutor(const VdfExecutorInterface *parentExecutor) :
70 Base(parentExecutor),
71 _engine(*this, &this->_dataManager)
72 { }
73
76 virtual ~EfSubExecutor() {}
77
80 virtual const VdfExecutorFactoryBase &GetFactory() const override final {
81 return _factory;
82 }
83
84protected:
85
88 virtual void _Run(
89 const VdfSchedule &schedule,
90 const VdfRequest &computeRequest,
91 VdfExecutorErrorLogger *errorLogger);
92
93private:
94
97 void _ClearData();
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
110
111template <template <typename> class EngineType, typename DataManagerType>
112const typename EfSubExecutor<EngineType, DataManagerType>::_Factory
113 EfSubExecutor<EngineType, DataManagerType>::_factory;
114
115template <template <typename> class EngineType, typename DataManagerType>
116void
117EfSubExecutor<EngineType, DataManagerType>::_Run(
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", "EfSubExecutor::Run");
129
130 _engine.RunSchedule(schedule, computeRequest, errorLogger);
131}
132
133template <template <typename> class EngineType, typename DataManagerType>
134void
135EfSubExecutor<EngineType, DataManagerType>::_ClearData()
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
147PXR_NAMESPACE_CLOSE_SCOPE
148
149#endif
Scoped (i.e.
Definition: mallocTag.h:249
A client may instantiate an object of this class and set it in an executor, to collect errors that ma...
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
Contains a specification of how to execute a particular VdfNetwork.
Definition: schedule.h:41
Executor used in speculation.