32#include "task/PxTask.h"
33#include "foundation/PxUserAllocated.h"
34#include "foundation/PxAtomic.h"
35#include "foundation/PxMutex.h"
36#include "foundation/PxInlineArray.h"
37#include "foundation/PxFPU.h"
66 virtual void runInternal()=0;
85 virtual void runInternal()=0;
88 template <
class T,
void (T::*Fn)(physx::PxBaseTask*) >
93 DelegateTask(PxU64 contextID, T* obj,
const char* name) :
Cm::Task(contextID), mObj(obj), mName(name) {}
105 virtual void runInternal()
115 void setObject(T* obj) { mObj = obj; }
137 virtual void runInternal() {}
139 virtual const char*
getName()
const {
return mName; }
147 if (!physx::PxAtomicDecrement(&mRefCount))
150 physx::PxAtomicIncrement(&mRefCount);
151 mNotifySubmission =
false;
152 PX_ASSERT(mReferencesToRemove.
empty());
153 for (PxU32 i = 0; i < mDependents.
size(); i++)
154 mReferencesToRemove.
pushBack(mDependents[i]);
166 physx::PxAtomicIncrement(&mRefCount);
167 mNotifySubmission =
true;
193 physx::PxAtomicIncrement(&mRefCount);
197 mNotifySubmission =
true;
211 const PxU32 contCount = mReferencesToRemove.
size();
212 referencesToRemove.
reserve(contCount);
213 for (PxU32 i=0; i < contCount; ++i)
214 referencesToRemove.
pushBack(mReferencesToRemove[i]);
216 mReferencesToRemove.
clear();
218 if (mNotifySubmission)
224 physx::PxAtomicDecrement(&mRefCount);
234 for (PxU32 i=0; i < referencesToRemove.
size(); ++i)
239 volatile PxI32 mRefCount;
243 bool mNotifySubmission;
251 template <
class T,
void (T::*Fn)(physx::PxBaseTask*) >
258 virtual void runInternal()
261 (mObj->*Fn)(continuation);
264 void setObject(T* obj) { mObj = obj; }
virtual void run()
The user-implemented run method where the task's work should be performed.
Definition CmTask.h:75
Specialization of FanoutTask class in order to provide the delegation mechanism.
Definition CmTask.h:253
virtual const char * getName() const
Return a user-provided task name for profiling purposes.
Definition CmTask.h:110
virtual void run()
The user-implemented run method where the task's work should be performed.
Definition CmTask.h:95
A task that maintains a list of dependent tasks.
Definition CmTask.h:132
virtual void addReference()
Increases reference count.
Definition CmTask.h:163
PX_INLINE void setTaskManager(physx::PxTaskManager &tm)
Definition CmTask.h:181
virtual void release()
Definition CmTask.h:204
virtual void removeReference()
Definition CmTask.h:144
virtual const char * getName() const
Return a user-provided task name for profiling purposes.
Definition CmTask.h:139
PX_INLINE PxI32 getReference() const
Return the ref-count for this task.
Definition CmTask.h:173
PX_INLINE void addDependent(physx::PxBaseTask &dependent)
Definition CmTask.h:190
virtual void run()
The user-implemented run method where the task's work should be performed.
Definition CmTask.h:56
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
PX_INLINE void clear()
Definition PxArray.h:250
PX_FORCE_INLINE bool empty() const
Definition PxArray.h:261
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
PX_INLINE void reserve(const uint32_t capacity)
Definition PxArray.h:486
Base class of all task types.
Definition PxTask.h:45
virtual void addReference()=0
Implemented by derived implementation classes.
PxU64 mContextID
Context ID for profiler interface.
Definition PxTask.h:97
PX_FORCE_INLINE PxTaskManager * getTaskManager() const
Return PxTaskManager to which this task was submitted.
Definition PxTask.h:88
PxTaskManager * mTm
Owning PxTaskManager instance.
Definition PxTask.h:98
virtual void submitTask(PxBaseTask &task)=0
Called by the TaskManager when a task is to be queued for execution.
Definition PxInlineArray.h:43
A PxBaseTask implementation with immediate execution and simple dependencies.
Definition PxTask.h:209
PxBaseTask * mCont
Continuation task, can be NULL.
Definition PxTask.h:306
The PxTaskManager interface.
Definition PxTaskManager.h:81
virtual PxCpuDispatcher * getCpuDispatcher() const =0
Get the user-provided dispatcher object for CPU tasks.
Definition PxUserAllocated.h:43
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39