PxThreadT

Defined in include/foundation/PxThread.h

Inheritance Relationships

Base Types

template<typename Alloc = PxReflectionAllocator<PxThreadImpl>>
class PxThreadT : protected PxReflectionAllocator<PxThreadImpl>, public PxUserAllocated, public PxRunnable

Thread abstraction API.

Public Types

typedef PxThreadImpl::Id Id

Public Functions

inline PxThreadT(const Alloc &alloc = Alloc())

Construct (but do not start) the thread object.

Executes in the context of the spawning thread

inline PxThreadT(PxThreadImpl::ExecuteFn fn, void *arg, const char *name, const Alloc &alloc = Alloc())

Construct and start the the thread, passing the given arg to the given fn.

(pthread style)

inline virtual ~PxThreadT()

Deallocate all resources associated with the thread.

Should be called in the context of the spawning thread.

inline void start(PxU32 stackSize = PxThreadImpl::getDefaultStackSize())

start the thread running.

Called in the context of the spawning thread.

inline void kill()

Violently kill the current thread.

Blunt instrument, not recommended since it can leave all kinds of things unreleased (stack, memory, mutexes…) Should be called in the context of the spawning thread.

inline virtual void execute(void)

The virtual execute() method is the user defined function that will run in the new thread.

Called in the context of the spawned thread.

inline void signalQuit()

stop the thread.

Signals the spawned thread that it should stop, so the thread should check regularly

inline bool waitForQuit()

Wait for a thread to stop.

Should be called in the context of the spawning thread. Returns false if the thread has not been started.

inline bool quitIsSignalled()

check whether the thread is signalled to quit.

Called in the context of the spawned thread.

inline void quit()

Cleanly shut down this thread.

Called in the context of the spawned thread.

inline PxU32 setAffinityMask(PxU32 mask)
inline void setPriority(PxThreadPriority::Enum prio)

Set thread priority.

inline void setName(const char *name)

set the thread’s name

inline void *operator new(size_t, void *address)
template<typename Alloc>
inline void *operator new(size_t size, Alloc alloc, const char *fileName, int line)
template<typename Alloc>
inline void *operator new(size_t size, size_t, Alloc alloc, const char *fileName, int line)
inline void operator delete(void*, void*)
template<typename Alloc>
inline void operator delete(void *ptr, Alloc alloc, const char *fileName, int line)
inline void operator delete(void *ptr)
template<typename Alloc>
inline void *operator new[](size_t size, Alloc alloc, const char *fileName, int line)
template<typename Alloc>
inline void *operator new[](size_t size, size_t, Alloc alloc, const char *fileName, int line)
template<typename Alloc>
inline void operator delete[](void *ptr, Alloc alloc, const char *fileName, int line)
inline void operator delete[](void *ptr)

Public Static Functions

static inline PxThreadPriority::Enum getPriority(PxThreadImpl::Id threadId)
static inline void sleep(PxU32 ms)

Put the current thread to sleep for the given number of milliseconds.

static inline void yield()

Yield the current thread’s slot on the CPU.

static inline void yieldProcesor()

Inform the processor that we’re in a busy wait to give it a chance to do something clever yield() yields the thread, while yieldProcessor() aims to yield the processor.

static inline PxU32 getDefaultStackSize()
static inline PxThreadImpl::Id getId()
static inline PxU32 getNbPhysicalCores()

Protected Functions

inline void *allocate(size_t size, const char *filename, int line)
inline void deallocate(void *ptr)