#pragma section-numbers off #pragma camelcase off = SDL_CreateMutex = Use this function to create a new mutex. <> == Syntax == {{{#!highlight cpp SDL_mutex* SDL_CreateMutex(void) }}} == Return Value == Returns the initialized and unlocked mutex or NULL on failure; call [[SDL_GetError]]() for more information. == Code Examples == ## Begin Mutex Example {{{#!highlight cpp SDL_mutex *mutex; mutex = SDL_CreateMutex(); if (!mutex) { fprintf(stderr, "Couldn't create mutex\n"); return; } if (SDL_LockMutex(mutex) == 0) { /* Do stuff while mutex is locked */ SDL_UnlockMutex(mutex); } else { fprintf(stderr, "Couldn't lock mutex\n"); } SDL_DestroyMutex(mutex); }}} ## End Mutex Example == Remarks == Calls to [[SDL_LockMutex]]() will not return while the mutex is locked by another thread. See [[SDL_TryLockMutex]]() to attempt to lock without blocking. SDL mutexes are reentrant. == Related Functions == .[[SDL_DestroyMutex]] .[[SDL_LockMutex]] .[[SDL_TryLockMutex]] .[[SDL_UnlockMutex]] ---- [[CategoryAPI]], [[CategoryMutex]]