Typedefs | |
typedef void * | AtCritSec |
Opaque data type for a critical section. | |
Functions | |
AI_API void | AiCritSecInit (AtCritSec *cs) |
Initializes a critical section variable. More... | |
AI_API void | AiCritSecInitRecursive (AtCritSec *cs) |
Initializes a recursive critical section variable. More... | |
AI_API void | AiCritSecClose (AtCritSec *cs) |
Releases all resources used by a critical section variable, so it cannot be used again. More... | |
AI_API void | AiCritSecEnter (AtCritSec *cs) |
Enters a critical section. More... | |
AI_API void | AiCritSecLeave (AtCritSec *cs) |
Leaves a critical section. More... | |
AI_API void AiCritSecInit | ( | AtCritSec * | cs | ) |
Initializes a critical section variable.
A critical section must be initialized before it can be used by any other functions, and should be coupled with a call to AiCritSecClose() when it is no longer needed.
Usage example:
cs | pointer to an allocated critical section |
AI_API void AiCritSecInitRecursive | ( | AtCritSec * | cs | ) |
Initializes a recursive critical section variable.
When creating a critical section, you can choose if you want support for re-entrancy or not. If your code might enter a critical section while it is currently inside the same critical section, you need support for recursion. Note that on Windows all critical sections are recursive, but this is not the case with pthreads-based Unix/Linux/OSX systems.
Two separate methods are provided to maintain backwards compatibility. Only the setup of the critical section depends on this property - the other calls work the same regardless of the type.
cs | pointer to an allocated critical section |
AI_API void AiCritSecClose | ( | AtCritSec * | cs | ) |
Releases all resources used by a critical section variable, so it cannot be used again.
cs | pointer to a critical section |
AI_API void AiCritSecEnter | ( | AtCritSec * | cs | ) |
Enters a critical section.
This function enforces that no more than one thread is in the critical section at any given time. A code block between calls to AiCritSecEnter() and AiCritSecLeave() is locked and guaranteed not to overlap with itself.
cs | pointer to a critical section |
AI_API void AiCritSecLeave | ( | AtCritSec * | cs | ) |