28 #include "SDL_thread.h"
44 if (pthread_cond_init(&cond->cond,
NULL) < 0) {
58 pthread_cond_destroy(&cond->cond);
74 if (pthread_cond_signal(&cond->cond) != 0) {
91 if (pthread_cond_broadcast(&cond->cond) != 0) {
101 struct timeval delta;
102 struct timespec abstime;
105 return SDL_SetError(
"Passed a NULL condition variable");
108 gettimeofday(&delta,
NULL);
110 abstime.tv_sec = delta.tv_sec + (ms / 1000);
111 abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
112 if (abstime.tv_nsec > 1000000000) {
114 abstime.tv_nsec -= 1000000000;
118 retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
129 retval =
SDL_SetError(
"pthread_cond_timedwait() failed");
141 return SDL_SetError(
"Passed a NULL condition variable");
142 }
else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond)
DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
DECLSPEC void SDLCALL SDL_free(void *mem)
DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond)
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond)
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void)
struct SDL_mutex SDL_mutex
#define SDL_MUTEX_TIMEDOUT
DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)