39 #include "blocxx/BLOCXX_config.h"
44 namespace BLOCXX_NAMESPACE
47 namespace 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);
79 #else //#if !defined (BLOCXX_NCR)
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);
100 #endif //#if !defined (BLOCXX_NCR)
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;
163 conditionPostWait(NonRecursiveMutex_t& handle, NonRecursiveMutexLockState& state)
168 #endif //#if defined (BLOCXX_USE_PTHREAD)
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;
207 conditionPreWait(NonRecursiveMutex_t& handle, NonRecursiveMutexLockState& state)
209 state.pmutex = &handle;
214 conditionPostWait(NonRecursiveMutex_t& handle, NonRecursiveMutexLockState& state)
219 #endif //#if defined(BLOCXX_WIN32)