zenilib: zenilib/jni/external/sdl/src/thread/generic/SDL_syscond.c File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
SDL_syscond.c File Reference
`#include "SDL_config.h"`
`#include "SDL_thread.h"`

Go to the source code of this file.

## Functions

int | SDL_CondBroadcast (SDL_cond *cond)
int | SDL_CondSignal (SDL_cond *cond)
int | SDL_CondWait (SDL_cond *cond, SDL_mutex *mutex)
int | SDL_CondWaitTimeout (SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
SDL_cond * | SDL_CreateCond (void)
void | SDL_DestroyCond (SDL_cond *cond)

## Function Documentation

int SDL_CondBroadcast | ( | SDL_cond * | cond | ) |

Restart all threads that are waiting on the condition variable.

Returns
  0 or -1 on error.

Definition at line 106 of file SDL_syscond.c.

References i, SDL_LockMutex(), SDL_SemPost(), SDL_SemWait(), SDL_SetError(), and SDL_UnlockMutex().

int SDL_CondSignal | ( | SDL_cond * | cond | ) |

Restart one of the threads that are waiting on the condition variable.

Returns
  0 or -1 on error.

Definition at line 82 of file SDL_syscond.c.

References SDL_LockMutex(), SDL_SemPost(), SDL_SemWait(), SDL_SetError(), and SDL_UnlockMutex().

int SDL_CondWait | ( | SDL_cond * | cond,
|  | SDL_mutex * | mutex
| ) |  |

Wait on the condition variable, unlocking the provided mutex.

Warning
  The mutex must be locked before entering this function!

The mutex is re-locked once the condition variable is signaled.

Returns
  0 when it is signaled, or -1 on error.

Definition at line 215 of file SDL_syscond.c.

References SDL_CondWaitTimeout(), and SDL_MUTEX_MAXWAIT.

int SDL_CondWaitTimeout | ( | SDL_cond * | cond,
|  | SDL_mutex * | mutex,
|  | Uint32 | ms
| ) |  |

Waits for at most `ms` milliseconds, and returns 0 if the condition variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not signaled in the allotted time, and -1 on error.

Warning
  On some platforms this function is implemented by looping with a delay of 1 ms, and so should be avoided if possible.

Definition at line 160 of file SDL_syscond.c.

References SDL_LockMutex(), SDL_MUTEX_MAXWAIT, SDL_SemPost(), SDL_SemWait(), SDL_SemWaitTimeout(), SDL_SetError(), and SDL_UnlockMutex().

SDL_cond* SDL_CreateCond | ( | void |  | ) |

Create a condition variable.

Typical use of condition variables:

Thread A: SDL_LockMutex(lock); while ( ! condition ) { SDL_CondWait(cond, lock); } SDL_UnlockMutex(lock);

Thread B: SDL_LockMutex(lock); ... condition = true; ... SDL_CondSignal(cond); SDL_UnlockMutex(lock);

There is some discussion whether to signal the condition variable with the mutex locked or not. There is some potential performance benefit to unlocking first on some platforms, but there are some potential race conditions depending on how your code is structured.

In general it's safer to signal the condition variable while the mutex is locked.

Definition at line 42 of file SDL_syscond.c.

References NULL, SDL_CreateMutex(), SDL_CreateSemaphore(), SDL_DestroyCond(), SDL_malloc(), and SDL_OutOfMemory.

void SDL_DestroyCond | ( | SDL_cond * | cond | ) |

Destroy a condition variable.

Definition at line 64 of file SDL_syscond.c.

References SDL_DestroyMutex(), SDL_DestroySemaphore(), and SDL_free().