PxTaskManager.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27 
28 #ifndef PXTASK_PXTASKMANAGER_H
29 #define PXTASK_PXTASKMANAGER_H
30 
31 #include "task/PxTaskDefine.h"
34 
35 namespace physx
36 {
38 
39 class PxBaseTask;
40 class PxTask;
42 typedef unsigned int PxTaskID;
43 
52 struct PxTaskType
53 {
57  enum Enum
58  {
62  };
63 };
64 
65 class PxCpuDispatcher;
66 
79 {
80 public:
81 
89  virtual void setCpuDispatcher(PxCpuDispatcher& ref) = 0;
90 
98  virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
99 
107  virtual void resetDependencies() = 0;
108 
116  virtual void startSimulation() = 0;
117 
121  virtual void stopSimulation() = 0;
122 
128  virtual void taskCompleted(PxTask& task) = 0;
129 
136  virtual PxTaskID getNamedTask(const char* name) = 0;
137 
146  virtual PxTaskID submitNamedTask(PxTask* task, const char* name, PxTaskType::Enum type = PxTaskType::TT_CPU) = 0;
147 
157 
165  virtual PxTask* getTaskFromID(PxTaskID id) = 0;
166 
170  virtual void release() = 0;
171 
175  static PxTaskManager* createTaskManager(PxErrorCallback& errorCallback, PxCpuDispatcher* = 0);
176 
177 protected:
178  virtual ~PxTaskManager() {}
179 
182  virtual void finishBefore(PxTask& task, PxTaskID taskID) = 0;
183  virtual void startAfter(PxTask& task, PxTaskID taskID) = 0;
184 
185  virtual void addReference(PxTaskID taskID) = 0;
186  virtual void decrReference(PxTaskID taskID) = 0;
187  virtual int32_t getReference(PxTaskID taskID) const = 0;
188 
189  virtual void decrReference(PxLightCpuTask&) = 0;
190  virtual void addReference(PxLightCpuTask&) = 0;
191 
194  friend class PxBaseTask;
195  friend class PxTask;
196  friend class PxLightCpuTask;
197 };
198 
200 
201 } // end physx namespace
202 
203 
204 #endif // PXTASK_PXTASKMANAGER_H
Definition: GuContactBuffer.h:37
Base class of all task types.
Definition: PxTask.h:44
User defined interface class. Used by the library to emit debug information.
Definition: PxErrorCallback.h:51
virtual void startSimulation()=0
Called by the owning scene to start the task graph.
virtual void stopSimulation()=0
Called by the owning scene at the end of a simulation step.
unsigned int PxTaskID
Definition: PxTaskManager.h:41
Return code when attempting to find a task that does not exist.
Definition: PxTaskManager.h:60
virtual ~PxTaskManager()
Definition: PxTaskManager.h:178
virtual void resetDependencies()=0
Reset any dependencies between Tasks.
A PxBaseTask implementation with immediate execution and simple dependencies.
Definition: PxTask.h:208
#define PX_POP_PACK
Definition: PxPreprocessor.h:330
virtual void setCpuDispatcher(PxCpuDispatcher &ref)=0
Set the user-provided dispatcher object for CPU tasks.
PxTask will be run on the CPU.
Definition: PxTaskManager.h:59
virtual PxTaskID getNamedTask(const char *name)=0
Retrieve a task by name.
Enum
Identifies the type of each heavyweight PxTask object.
Definition: PxTaskManager.h:57
virtual PxTaskID submitNamedTask(PxTask *task, const char *name, PxTaskType::Enum type=PxTaskType::TT_CPU)=0
Submit a task with a unique name.
Identifies the type of each heavyweight PxTask object.
Definition: PxTaskManager.h:52
The PxTaskManager interface.
Definition: PxTaskManager.h:78
PxTask execution has been completed.
Definition: PxTaskManager.h:61
virtual void taskCompleted(PxTask &task)=0
Called by the worker threads to inform the PxTaskManager that a task has completed processing...
static PxTaskManager * createTaskManager(PxErrorCallback &errorCallback, PxCpuDispatcher *=0)
Construct a new PxTaskManager instance with the given [optional] dispatchers.
virtual PxTaskID submitUnnamedTask(PxTask &task, PxTaskType::Enum type=PxTaskType::TT_CPU)=0
Submit an unnamed task.
#define PX_PUSH_PACK_DEFAULT
Definition: PxPreprocessor.h:329
A PxBaseTask implementation with deferred execution and full dependencies.
Definition: PxTask.h:110
virtual void release()=0
Release the PxTaskManager object, referenced dispatchers will not be released.
A CpuDispatcher is responsible for scheduling the execution of tasks passed to it by the SDK...
Definition: PxCpuDispatcher.h:49
virtual PxTask * getTaskFromID(PxTaskID id)=0
Retrieve a task given a task ID.
virtual PxCpuDispatcher * getCpuDispatcher() const =0
Get the user-provided dispatcher object for CPU tasks.