Home | History | Annotate | Download | only in win32

Lines Matching defs:mutex

24 /* Mutex functions using the Win32 API */
36 /* Create a mutex */
39 SDL_mutex *mutex;
41 /* Allocate mutex memory */
42 mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
43 if ( mutex ) {
44 /* Create the mutex, with initial value signaled */
45 mutex->id = CreateMutex(NULL, FALSE, NULL);
46 if ( ! mutex->id ) {
47 SDL_SetError("Couldn't create mutex");
48 SDL_free(mutex);
49 mutex = NULL;
54 return(mutex);
57 /* Free the mutex */
58 void SDL_DestroyMutex(SDL_mutex *mutex)
60 if ( mutex ) {
61 if ( mutex->id ) {
62 CloseHandle(mutex->id);
63 mutex->id = 0;
65 SDL_free(mutex);
69 /* Lock the mutex */
70 int SDL_mutexP(SDL_mutex *mutex)
72 if ( mutex == NULL ) {
73 SDL_SetError("Passed a NULL mutex");
76 if ( WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED ) {
77 SDL_SetError("Couldn't wait on mutex");
83 /* Unlock the mutex */
84 int SDL_mutexV(SDL_mutex *mutex)
86 if ( mutex == NULL ) {
87 SDL_SetError("Passed a NULL mutex");
90 if ( ReleaseMutex(mutex->id) == FALSE ) {
91 SDL_SetError("Couldn't release mutex");