39#include "blocxx/BLOCXX_config.h"
47namespace NonRecursiveMutexImpl
50#if defined (BLOCXX_USE_PTHREAD)
52#if !defined (BLOCXX_NCR)
61 pthread_mutexattr_t attr;
62 int res = pthread_mutexattr_init(&attr);
69 res = pthread_mutex_init(&handle.mutex, &attr);
70 pthread_mutexattr_destroy(&attr);
83 pthread_mutexattr_t attr;
84 int res = pthread_mutexattr_create(&attr);
91 res = pthread_mutex_init(&handle.mutex, attr);
92 pthread_mutexattr_delete(&attr);
114 switch (pthread_mutex_destroy(&handle.mutex))
137 int res = pthread_mutex_lock(&handle.mutex);
150 int res = pthread_mutex_unlock(&handle.mutex);
158 state.pmutex = &handle.mutex;
170#if defined(BLOCXX_WIN32)
175 if ((handle = CreateMutex(NULL, FALSE, NULL)))
185 ReleaseMutex(handle);
186 return (CloseHandle(handle) == 0) ? -2 : 0;
193 if (WaitForSingleObject(handle, INFINITE) != WAIT_FAILED)
203 return (ReleaseMutex(handle)) ? 0 : -1;
209 state.pmutex = &handle;
BLOCXX_COMMON_API int conditionPostWait(NonRecursiveMutex_t &handle, NonRecursiveMutexLockState &state)
BLOCXX_COMMON_API int destroyMutex(NonRecursiveMutex_t &handle)
Destroy a mutex previously created with createMutex.
BLOCXX_COMMON_API int acquireMutex(NonRecursiveMutex_t &handle)
Acquire the mutex specified by a given mutex handle.
BLOCXX_COMMON_API int releaseMutex(NonRecursiveMutex_t &handle)
Release a mutex that was previously acquired with the acquireMutex method.
BLOCXX_COMMON_API int conditionPreWait(NonRecursiveMutex_t &handle, NonRecursiveMutexLockState &state)
BLOCXX_COMMON_API int createMutex(NonRecursiveMutex_t &handle)
Create a platform specific mutext handle.