Final Platform Layer 0.9.8-beta
|
This section explains how to create and handling of Condition-Variables.
A Condition-Variable is a User-Level Object used to let Threads wait until a Condition-Variable is signaled or broadcasted.
Unlike Signals, Condition-Variables requires you to use a fplMutexHandle as a locking mechanism.
They cannot be shared across process boundaries but the number of Condition-Variables is only limited by the amount of memory you have.
Call fplConditionInit() with a pointer to fplConditionVariable as an argument, to initialize a Condition-Variable.
When you are done with that Condition-Variable, you need to call fplConditionDestroy() to release its internal resources.
Call fplConditionWait() with a pointer to fplConditionVariable and a pointer to fplMutexHandle as an argument, to let a thread wait on that Condition-Variable.
Also, you need to specify the number of milliseconds you want the Thread to wait. If FPL_TIMEOUT_INFINITE is passed, it will wait forever.
A Thread can only wait on one single Condition-Variable at a time - if you need to wait on multiple Condition-Variables, you should consider using Signals .
Call fplConditionSignal() with a pointer to fplConditionVariable, to signal any waiting Threads.
If you want to let multiple Threads waits on the same Condition-Variable, use fplConditionBroadcast() instead.
Call fplConditionBroadcast() with a pointer to fplConditionVariable, to signal all waiting Threads.
If you just need a single Thread to wait on the Condition-Variable, use fplConditionSignal() instead.