Home | History | Annotate | Download | only in pthread

Lines Matching defs:mutex

43 	SDL_mutex *mutex;
47 mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex));
48 if ( mutex ) {
57 if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
59 SDL_free(mutex);
60 mutex = NULL;
65 return(mutex);
68 void SDL_DestroyMutex(SDL_mutex *mutex)
70 if ( mutex ) {
71 pthread_mutex_destroy(&mutex->id);
72 SDL_free(mutex);
76 /* Lock the mutex */
77 int SDL_mutexP(SDL_mutex *mutex)
84 if ( mutex == NULL ) {
85 SDL_SetError("Passed a NULL mutex");
92 if ( mutex->owner == this_thread ) {
93 ++mutex->recursive;
99 if ( pthread_mutex_lock(&mutex->id) == 0 ) {
100 mutex->owner = this_thread;
101 mutex->recursive = 0;
108 if ( pthread_mutex_lock(&mutex->id) < 0 ) {
116 int SDL_mutexV(SDL_mutex *mutex)
120 if ( mutex == NULL ) {
121 SDL_SetError("Passed a NULL mutex");
127 /* We can only unlock the mutex if we own it */
128 if ( pthread_self() == mutex->owner ) {
129 if ( mutex->recursive ) {
130 --mutex->recursive;
134 the mutex and set the ownership before we reset it,
137 mutex->owner = 0;
138 pthread_mutex_unlock(&mutex->id);
141 SDL_SetError("mutex not owned by this thread");
146 if ( pthread_mutex_unlock(&mutex->id) < 0 ) {