Final Platform Layer 0.9.8-beta
|
This category contains functions/types for dealing with concurrent programming, such as threads, mutexes, conditions, etc. More...
Data Structures | |
struct | fplConditionVariable |
The condition variable structure. More... | |
union | fplInternalConditionVariable |
A union containing the internal condition variable for any platform. More... | |
union | fplInternalMutexHandle |
A union containing the internal mutex handle for any platform. More... | |
union | fplInternalSemaphoreHandle |
A union containing the internal semaphore handle for any platform. More... | |
union | fplInternalSignalHandle |
A union containing the internal signal handle for any platform. More... | |
union | fplInternalThreadHandle |
A union containing the thread handle for any platform. More... | |
struct | fplMutexHandle |
The mutex handle structure. More... | |
struct | fplSemaphoreHandle |
The semaphore handle structure. More... | |
struct | fplSignalHandle |
The signal handle structure. More... | |
struct | fplThreadHandle |
The thread handle structure. More... | |
struct | fplThreadParameters |
Contains creation parameters for fplThreadCreateWithParameters() More... | |
Typedefs | |
typedef void() | fpl_run_thread_callback(const fplThreadHandle *thread, void *data) |
A callback to execute user code inside another thread. | |
typedef struct fplConditionVariable | fplConditionVariable |
The condition variable structure. | |
typedef union fplInternalConditionVariable | fplInternalConditionVariable |
A union containing the internal condition variable for any platform. | |
typedef union fplInternalMutexHandle | fplInternalMutexHandle |
A union containing the internal mutex handle for any platform. | |
typedef union fplInternalSemaphoreHandle | fplInternalSemaphoreHandle |
A union containing the internal semaphore handle for any platform. | |
typedef union fplInternalSignalHandle | fplInternalSignalHandle |
A union containing the internal signal handle for any platform. | |
typedef union fplInternalThreadHandle | fplInternalThreadHandle |
A union containing the thread handle for any platform. | |
typedef struct fplMutexHandle | fplMutexHandle |
The mutex handle structure. | |
typedef struct fplSemaphoreHandle | fplSemaphoreHandle |
The semaphore handle structure. | |
typedef struct fplSignalHandle | fplSignalHandle |
The signal handle structure. | |
typedef enum fplSignalValue | fplSignalValue |
An enumeration of signal values. | |
typedef struct fplThreadHandle | fplThreadHandle |
Forward declared thread handle. | |
typedef struct fplThreadParameters | fplThreadParameters |
Contains creation parameters for fplThreadCreateWithParameters() | |
typedef enum fplThreadPriority | fplThreadPriority |
Defines all possible thread priorities. | |
typedef uint32_t | fplThreadState |
A type definition for mapping fplThreadState into a 32-bit integer. | |
typedef enum fplThreadStates | fplThreadStates |
An enumeration of thread states. | |
Enumerations | |
enum | fplSignalValue { fplSignalValue_Unset , fplSignalValue_Set } |
An enumeration of signal values. More... | |
enum | fplThreadPriority { fplThreadPriority_Unknown , fplThreadPriority_Idle , fplThreadPriority_Low , fplThreadPriority_Normal , fplThreadPriority_High , fplThreadPriority_RealTime , fplThreadPriority_Lowest , fplThreadPriority_Highest , fplThreadPriority_First , fplThreadPriority_Last } |
Defines all possible thread priorities. More... | |
enum | fplThreadStates { fplThreadState_Stopped , fplThreadState_Starting , fplThreadState_Running , fplThreadState_Stopping } |
An enumeration of thread states. More... | |
Functions | |
fpl_platform_api bool | fplConditionBroadcast (fplConditionVariable *condition) |
Wakes up all threads that wait on the given condition. | |
fpl_platform_api void | fplConditionDestroy (fplConditionVariable *condition) |
Releases the given condition and clears the structure to zero. | |
fpl_platform_api bool | fplConditionInit (fplConditionVariable *condition) |
Initialize s the given condition. | |
fpl_platform_api bool | fplConditionSignal (fplConditionVariable *condition) |
Wakes up one thread that waits on the given condition. | |
fpl_platform_api bool | fplConditionWait (fplConditionVariable *condition, fplMutexHandle *mutex, const fplTimeoutValue timeout) |
Sleeps on the given condition and releases the mutex when done. | |
fpl_platform_api uint32_t | fplGetCurrentThreadId () |
Gets the thread id for the current thread. | |
fpl_common_api const fplThreadHandle * | fplGetMainThread () |
Gets the thread handle for the main thread. | |
fpl_platform_api fplThreadPriority | fplGetThreadPriority (fplThreadHandle *thread) |
Retrieves the current thread priority from the OS from the given fplThreadHandle . | |
fpl_common_api fplThreadState | fplGetThreadState (fplThreadHandle *thread) |
Gets the current thread state for the given thread. | |
fpl_platform_api void | fplMutexDestroy (fplMutexHandle *mutex) |
Releases the given mutex and clears the structure to zero. | |
fpl_platform_api bool | fplMutexInit (fplMutexHandle *mutex) |
Initializes the given mutex. | |
fpl_platform_api bool | fplMutexLock (fplMutexHandle *mutex) |
Locks the given mutex and blocks any other threads. | |
fpl_platform_api bool | fplMutexTryLock (fplMutexHandle *mutex) |
Tries to lock the given mutex without blocking other threads. | |
fpl_platform_api bool | fplMutexUnlock (fplMutexHandle *mutex) |
Unlocks the given mutex. | |
fpl_platform_api void | fplSemaphoreDestroy (fplSemaphoreHandle *semaphore) |
Releases the internal semaphore resources. | |
fpl_platform_api bool | fplSemaphoreInit (fplSemaphoreHandle *semaphore, const uint32_t initialValue) |
Initializes the semaphore with the given initial value. | |
fpl_platform_api bool | fplSemaphoreRelease (fplSemaphoreHandle *semaphore) |
Increments the semaphore value by one. | |
fpl_platform_api bool | fplSemaphoreTryWait (fplSemaphoreHandle *semaphore) |
Tries to wait for the semaphore until it gets signaled or return immediately. | |
fpl_platform_api int32_t | fplSemaphoreValue (fplSemaphoreHandle *semaphore) |
Gets the current semaphore value. | |
fpl_platform_api bool | fplSemaphoreWait (fplSemaphoreHandle *semaphore, const fplTimeoutValue timeout) |
Waits for the semaphore until it gets signaled or the timeout has been reached. | |
fpl_platform_api bool | fplSetThreadPriority (fplThreadHandle *thread, const fplThreadPriority newPriority) |
Changes the thread priority to the given one, for the given fplThreadHandle . | |
fpl_platform_api void | fplSignalDestroy (fplSignalHandle *signal) |
Releases the given signal and clears the structure to zero. | |
fpl_platform_api bool | fplSignalInit (fplSignalHandle *signal, const fplSignalValue initialValue) |
Initializes the given signal. | |
fpl_platform_api bool | fplSignalReset (fplSignalHandle *signal) |
Resets the signal. | |
fpl_platform_api bool | fplSignalSet (fplSignalHandle *signal) |
Sets the signal and wakes up the given signal. | |
fpl_platform_api bool | fplSignalWaitForAll (fplSignalHandle **signals, const size_t count, const size_t stride, const fplTimeoutValue timeout) |
Waits until all the given signals are waked up. | |
fpl_platform_api bool | fplSignalWaitForAny (fplSignalHandle **signals, const size_t count, const size_t stride, const fplTimeoutValue timeout) |
Waits until any of the given signals wakes up or the timeout has been reached. | |
fpl_platform_api bool | fplSignalWaitForOne (fplSignalHandle *signal, const fplTimeoutValue timeout) |
Waits until the given signal is waked up. | |
fpl_platform_api fplThreadHandle * | fplThreadCreate (fpl_run_thread_callback *runFunc, void *data) |
Creates and starts a thread and returns the handle to it. | |
fpl_platform_api fplThreadHandle * | fplThreadCreateWithParameters (fplThreadParameters *parameters) |
Creates and starts a thread from the specified fplThreadParameters and returns the handle to it. | |
fpl_platform_api void | fplThreadSleep (const uint32_t milliseconds) |
Let the current thread sleep for the given amount of milliseconds. | |
fpl_platform_api bool | fplThreadTerminate (fplThreadHandle *thread) |
Forces the given thread to stop and release all underlying resources. | |
fpl_platform_api bool | fplThreadWaitForAll (fplThreadHandle **threads, const size_t count, const size_t stride, const fplTimeoutValue timeout) |
Wait until all given threads are done running or the given timeout has been reached. | |
fpl_platform_api bool | fplThreadWaitForAny (fplThreadHandle **threads, const size_t count, const size_t stride, const fplTimeoutValue timeout) |
Wait until one of the given threads is done running or the given timeout has been reached. | |
fpl_platform_api bool | fplThreadWaitForOne (fplThreadHandle *thread, const fplTimeoutValue timeout) |
Wait until the given thread is done running or the given timeout has been reached. | |
fpl_platform_api bool | fplThreadYield () |
Let the current thread yield execution to another thread that is ready to run on this core. | |
fpl_common_api size_t | GetAvailableThreadCount () |
Gets the number of available threads. | |
fpl_common_api size_t | GetUsedThreadCount () |
Gets the number of used/active threads. | |
This category contains functions/types for dealing with concurrent programming, such as threads, mutexes, conditions, etc.
typedef void() fpl_run_thread_callback(const fplThreadHandle *thread, void *data) |
A callback to execute user code inside another thread.
thread | The thread handle |
data | The user data pointer |
Definition at line 4587 of file final_platform_layer.h.
typedef struct fplThreadHandle fplThreadHandle |
Forward declared thread handle.
The thread handle structure.
Definition at line 4580 of file final_platform_layer.h.
typedef uint32_t fplThreadState |
A type definition for mapping fplThreadState into a 32-bit integer.
Definition at line 4550 of file final_platform_layer.h.
enum fplSignalValue |
An enumeration of signal values.
Enumerator | |
---|---|
fplSignalValue_Unset | Value is unset. |
fplSignalValue_Set | Value is set. |
Definition at line 4695 of file final_platform_layer.h.
enum fplThreadPriority |
Defines all possible thread priorities.
Enumerator | |
---|---|
fplThreadPriority_Unknown | Unknown priority. |
fplThreadPriority_Idle | Idle priority (Only when nothing is going on) |
fplThreadPriority_Low | Low priority. |
fplThreadPriority_Normal | Normal priority. |
fplThreadPriority_High | High priority. |
fplThreadPriority_RealTime | Realtime priority (Time critical) |
fplThreadPriority_Lowest | Lowest fplThreadPriority. |
fplThreadPriority_Highest | Highest fplThreadPriority. |
fplThreadPriority_First | First fplThreadPriority. |
fplThreadPriority_Last | Last fplThreadPriority. |
Definition at line 4553 of file final_platform_layer.h.
enum fplThreadStates |
An enumeration of thread states.
Enumerator | |
---|---|
fplThreadState_Stopped | Thread is stopped. |
fplThreadState_Starting | Thread is being started. |
fplThreadState_Running | Thread is still running. |
fplThreadState_Stopping | Thread is being stopped. |
Definition at line 4538 of file final_platform_layer.h.
fpl_platform_api bool fplConditionBroadcast | ( | fplConditionVariable * | condition | ) |
Wakes up all threads that wait on the given condition.
condition | The pointer to the fplConditionVariable structure |
fpl_platform_api void fplConditionDestroy | ( | fplConditionVariable * | condition | ) |
Releases the given condition and clears the structure to zero.
condition | The pointer to the fplConditionVariable structure |
fpl_platform_api bool fplConditionInit | ( | fplConditionVariable * | condition | ) |
Initialize s the given condition.
condition | The pointer to the fplConditionVariable structure |
fpl_platform_api bool fplConditionSignal | ( | fplConditionVariable * | condition | ) |
Wakes up one thread that waits on the given condition.
condition | The pointer to the fplConditionVariable structure |
fpl_platform_api bool fplConditionWait | ( | fplConditionVariable * | condition, |
fplMutexHandle * | mutex, | ||
const fplTimeoutValue | timeout | ||
) |
Sleeps on the given condition and releases the mutex when done.
condition | The pointer to the fplConditionVariable structure |
mutex | The pointer to the mutex handle fplMutexHandle structure |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api uint32_t fplGetCurrentThreadId | ( | ) |
Gets the thread id for the current thread.
fpl_common_api const fplThreadHandle * fplGetMainThread | ( | ) |
Gets the thread handle for the main thread.
fpl_platform_api fplThreadPriority fplGetThreadPriority | ( | fplThreadHandle * | thread | ) |
Retrieves the current thread priority from the OS from the given fplThreadHandle .
thread | The pointer to the fplThreadHandle structure |
fpl_common_api fplThreadState fplGetThreadState | ( | fplThreadHandle * | thread | ) |
Gets the current thread state for the given thread.
thread | The thread handle fplThreadHandle |
fpl_platform_api void fplMutexDestroy | ( | fplMutexHandle * | mutex | ) |
Releases the given mutex and clears the structure to zero.
mutex | The pointer to the fplMutexHandle structure |
fpl_platform_api bool fplMutexInit | ( | fplMutexHandle * | mutex | ) |
Initializes the given mutex.
mutex | The pointer to the fplMutexHandle structure |
fpl_platform_api bool fplMutexLock | ( | fplMutexHandle * | mutex | ) |
Locks the given mutex and blocks any other threads.
mutex | The pointer to the fplMutexHandle structure |
fpl_platform_api bool fplMutexTryLock | ( | fplMutexHandle * | mutex | ) |
Tries to lock the given mutex without blocking other threads.
mutex | The pointer to the fplMutexHandle structure |
fpl_platform_api bool fplMutexUnlock | ( | fplMutexHandle * | mutex | ) |
Unlocks the given mutex.
mutex | The pointer to the fplMutexHandle structure |
fpl_platform_api void fplSemaphoreDestroy | ( | fplSemaphoreHandle * | semaphore | ) |
Releases the internal semaphore resources.
semaphore | The pointer to the fplSemaphoreHandle structure |
fpl_platform_api bool fplSemaphoreInit | ( | fplSemaphoreHandle * | semaphore, |
const uint32_t | initialValue | ||
) |
Initializes the semaphore with the given initial value.
semaphore | The pointer to the fplSemaphoreHandle structure |
initialValue | The initial value |
fpl_platform_api bool fplSemaphoreRelease | ( | fplSemaphoreHandle * | semaphore | ) |
Increments the semaphore value by one.
semaphore | The pointer to the fplSemaphoreHandle structure |
fpl_platform_api bool fplSemaphoreTryWait | ( | fplSemaphoreHandle * | semaphore | ) |
Tries to wait for the semaphore until it gets signaled or return immediately.
semaphore | The pointer to the fplSemaphoreHandle structure |
fpl_platform_api int32_t fplSemaphoreValue | ( | fplSemaphoreHandle * | semaphore | ) |
Gets the current semaphore value.
semaphore | The pointer to the fplSemaphoreHandle structure |
fpl_platform_api bool fplSemaphoreWait | ( | fplSemaphoreHandle * | semaphore, |
const fplTimeoutValue | timeout | ||
) |
Waits for the semaphore until it gets signaled or the timeout has been reached.
semaphore | The pointer to the fplSemaphoreHandle structure |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api bool fplSetThreadPriority | ( | fplThreadHandle * | thread, |
const fplThreadPriority | newPriority | ||
) |
Changes the thread priority to the given one, for the given fplThreadHandle .
thread | The pointer to the fplThreadHandle structure |
newPriority | The new fplThreadPriority for the given thread |
fpl_platform_api void fplSignalDestroy | ( | fplSignalHandle * | signal | ) |
Releases the given signal and clears the structure to zero.
signal | The pointer to the fplSignalHandle structure |
fpl_platform_api bool fplSignalInit | ( | fplSignalHandle * | signal, |
const fplSignalValue | initialValue | ||
) |
Initializes the given signal.
signal | The pointer to the fplSignalHandle structure |
initialValue | The initial value the signal is set to |
fpl_platform_api bool fplSignalReset | ( | fplSignalHandle * | signal | ) |
Resets the signal.
signal | The pointer to the fplSignalHandle structure |
fpl_platform_api bool fplSignalSet | ( | fplSignalHandle * | signal | ) |
Sets the signal and wakes up the given signal.
signal | The pointer to the fplSignalHandle structure |
fpl_platform_api bool fplSignalWaitForAll | ( | fplSignalHandle ** | signals, |
const size_t | count, | ||
const size_t | stride, | ||
const fplTimeoutValue | timeout | ||
) |
Waits until all the given signals are waked up.
signals | The pointer to the first fplSignalHandle pointer |
count | The number of signals |
stride | The size in bytes to the next signal handle. When this is set to zero, the array default is used. |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api bool fplSignalWaitForAny | ( | fplSignalHandle ** | signals, |
const size_t | count, | ||
const size_t | stride, | ||
const fplTimeoutValue | timeout | ||
) |
Waits until any of the given signals wakes up or the timeout has been reached.
signals | The pointer to the first fplSignalHandle pointer |
count | The number of signals |
stride | The size in bytes to the next signal handle. When this is set to zero, the array default is used. |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api bool fplSignalWaitForOne | ( | fplSignalHandle * | signal, |
const fplTimeoutValue | timeout | ||
) |
Waits until the given signal is waked up.
signal | The pointer to the fplSignalHandle structure |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api fplThreadHandle * fplThreadCreate | ( | fpl_run_thread_callback * | runFunc, |
void * | data | ||
) |
Creates and starts a thread and returns the handle to it.
runFunc | The pointer to the fpl_run_thread_callback |
data | The user data pointer passed to the execution function callback |
fpl_platform_api fplThreadHandle * fplThreadCreateWithParameters | ( | fplThreadParameters * | parameters | ) |
Creates and starts a thread from the specified fplThreadParameters and returns the handle to it.
parameters | The pointer to the fplThreadParameters |
fpl_platform_api void fplThreadSleep | ( | const uint32_t | milliseconds | ) |
Let the current thread sleep for the given amount of milliseconds.
milliseconds | Number of milliseconds to sleep |
fpl_platform_api bool fplThreadTerminate | ( | fplThreadHandle * | thread | ) |
Forces the given thread to stop and release all underlying resources.
thread | The pointer to the fplThreadHandle structure |
fpl_platform_api bool fplThreadWaitForAll | ( | fplThreadHandle ** | threads, |
const size_t | count, | ||
const size_t | stride, | ||
const fplTimeoutValue | timeout | ||
) |
Wait until all given threads are done running or the given timeout has been reached.
threads | The pointer to the first fplThreadHandle pointer |
count | The number of threads |
stride | The size in bytes to the next thread handle. When this is set to zero, the array default is used. |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api bool fplThreadWaitForAny | ( | fplThreadHandle ** | threads, |
const size_t | count, | ||
const size_t | stride, | ||
const fplTimeoutValue | timeout | ||
) |
Wait until one of the given threads is done running or the given timeout has been reached.
threads | The pointer to the first fplThreadHandle pointer |
count | The number of threads |
stride | The size in bytes to the next thread handle. When this is set to zero, the array default is used. |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api bool fplThreadWaitForOne | ( | fplThreadHandle * | thread, |
const fplTimeoutValue | timeout | ||
) |
Wait until the given thread is done running or the given timeout has been reached.
thread | The pointer to the fplThreadHandle structure |
timeout | The number of milliseconds to wait. When this is set to FPL_TIMEOUT_INFINITE it will wait infinitely. |
fpl_platform_api bool fplThreadYield | ( | ) |
Let the current thread yield execution to another thread that is ready to run on this core.
fpl_common_api size_t GetAvailableThreadCount | ( | ) |
Gets the number of available threads.
fpl_common_api size_t GetUsedThreadCount | ( | ) |
Gets the number of used/active threads.