Wii U ThreadDriver, built on coreinit's OSThread/OSMutex/OSCondition. More...
#include <WutThreadDriver.h>
Public Member Functions | |
| void | init () override |
| Initializes the threading backend. | |
| void | shutdown () override |
| Shuts the threading backend down. Every thread must already have been joined. | |
| bool | createThread (ThreadEntry entry, void *arg, uint32_t stackSize, ThreadPriority priority, void **outHandle) override |
| Creates and starts a thread running entry(arg). | |
| void | joinThread (void *thread) override |
| Blocks until the thread exits, then releases the handle. | |
| void | cancelThread (void *thread) override |
| Requests the thread stop running and releases the handle without blocking on it. | |
| void | suspendThread (void *thread) override |
| Suspends a running thread until resumeThread() is called. | |
| void | resumeThread (void *thread) override |
| Resumes a thread suspended with suspendThread(). | |
| bool | isThreadSuspended (void *thread) override |
| void * | createMutex () override |
| Creates an unlocked mutex. | |
| void | destroyMutex (void *mutex) override |
| Destroys a mutex created by createMutex(). It must not be locked. | |
| void | lockMutex (void *mutex) override |
| Blocks until the mutex is acquired. | |
| void | unlockMutex (void *mutex) override |
| Releases a mutex held by the calling thread. | |
| void * | createCond () override |
| Creates a condition variable. | |
| void | destroyCond (void *cond) override |
| Destroys a condition variable created by createCond(). No thread may be waiting on it. | |
| void | waitCond (void *cond, void *mutex) override |
| Atomically unlocks mutex and blocks the calling thread until signalCond() is called, then reacquires mutex before returning. | |
| void | signalCond (void *cond) override |
| Wakes every thread currently blocked in waitCond() on this condition variable. | |
| void | sleepMilliseconds (uint32_t ms) override |
| Sleeps the calling thread for at least the given duration. | |
| uintptr_t | getCurrentThreadId () override |
| Returns an opaque, comparable identifier for the calling thread. | |
Wii U ThreadDriver, built on coreinit's OSThread/OSMutex/OSCondition.
Definition at line 11 of file WutThreadDriver.h.
|
overridevirtual |
Requests the thread stop running and releases the handle without blocking on it.
This is a best-effort operation - not every backend can truly terminate a thread mid-flight (e.g. libogc/LWP has no cancel primitive, so that backend can only suspend it and leak its stack). Prefer having the thread watch its own exit condition and calling joinThread() to stop it cleanly wherever possible; reach for cancelThread() only as a last resort.
Implements ThreadDriver.
Definition at line 124 of file WutThreadDriver.cpp.
|
overridevirtual |
Creates a condition variable.
Returns an opaque backend-defined handle, or nullptr on failure.
Implements ThreadDriver.
Definition at line 198 of file WutThreadDriver.cpp.
|
overridevirtual |
Creates an unlocked mutex.
Returns an opaque backend-defined handle, or nullptr on failure.
Implements ThreadDriver.
Definition at line 167 of file WutThreadDriver.cpp.
|
overridevirtual |
Creates and starts a thread running entry(arg).
Writes the new handle to *outHandle and returns true on success, or leaves *outHandle untouched and returns false on failure.
*outHandle is written before the new thread is scheduled to run, not after this call returns to the caller - entry() is allowed to reference *outHandle itself (e.g. to suspend/query its own thread) without racing the assignment.
Implements ThreadDriver.
Definition at line 60 of file WutThreadDriver.cpp.
|
overridevirtual |
Destroys a condition variable created by createCond(). No thread may be waiting on it.
Implements ThreadDriver.
Definition at line 205 of file WutThreadDriver.cpp.
|
overridevirtual |
Destroys a mutex created by createMutex(). It must not be locked.
Implements ThreadDriver.
Definition at line 174 of file WutThreadDriver.cpp.
|
overridevirtual |
Returns an opaque, comparable identifier for the calling thread.
Unlike the thread handles above, this does NOT require the thread to have been created via createThread() - it also identifies the app's original/main thread, which is never itself a Thread object. Two calls from the same thread must compare equal; that's the only guarantee callers may rely on.
Implements ThreadDriver.
Definition at line 239 of file WutThreadDriver.cpp.
|
overridevirtual |
Initializes the threading backend.
Implements ThreadDriver.
Definition at line 52 of file WutThreadDriver.cpp.
|
overridevirtual |
Implements ThreadDriver.
Definition at line 159 of file WutThreadDriver.cpp.
|
overridevirtual |
Blocks until the thread exits, then releases the handle.
Implements ThreadDriver.
Definition at line 112 of file WutThreadDriver.cpp.
|
overridevirtual |
Blocks until the mutex is acquired.
Implements ThreadDriver.
Definition at line 182 of file WutThreadDriver.cpp.
|
overridevirtual |
Resumes a thread suspended with suspendThread().
Implements ThreadDriver.
Definition at line 151 of file WutThreadDriver.cpp.
|
overridevirtual |
Shuts the threading backend down. Every thread must already have been joined.
Implements ThreadDriver.
Definition at line 56 of file WutThreadDriver.cpp.
|
overridevirtual |
Wakes every thread currently blocked in waitCond() on this condition variable.
This is a broadcast-only operation.
Implements ThreadDriver.
Definition at line 223 of file WutThreadDriver.cpp.
|
overridevirtual |
Sleeps the calling thread for at least the given duration.
Implements ThreadDriver.
Definition at line 234 of file WutThreadDriver.cpp.
|
overridevirtual |
Suspends a running thread until resumeThread() is called.
Implements ThreadDriver.
Definition at line 143 of file WutThreadDriver.cpp.
|
overridevirtual |
Releases a mutex held by the calling thread.
Implements ThreadDriver.
Definition at line 190 of file WutThreadDriver.cpp.
|
overridevirtual |
Atomically unlocks mutex and blocks the calling thread until signalCond() is called, then reacquires mutex before returning.
mutex must be locked by the calling thread on entry.
Implements ThreadDriver.
Definition at line 213 of file WutThreadDriver.cpp.