17#ifndef MI_PLATFORM_WINDOWS
21#include <mi/base/miwindows.h>
123#ifndef MI_PLATFORM_WINDOWS
125 pthread_mutex_t m_mutex;
217#ifndef MI_PLATFORM_WINDOWS
219 pthread_mutex_t m_mutex;
222 CRITICAL_SECTION m_critical_section;
226#ifndef MI_FOR_DOXYGEN_ONLY
229#ifdef MI_PLATFORM_WINDOWS
230 : m_srwlock(
SRWLOCK_INIT),
234#ifndef MI_PLATFORM_WINDOWS
235 pthread_mutexattr_t mutex_attributes;
236 pthread_mutexattr_init( &mutex_attributes);
237 pthread_mutexattr_settype( &mutex_attributes,
PTHREAD_MUTEX_ERRORCHECK);
238 pthread_mutex_init( &m_mutex, &mutex_attributes);
244#ifndef MI_PLATFORM_WINDOWS
245 int result = pthread_mutex_destroy( &m_mutex);
257#ifndef MI_PLATFORM_WINDOWS
258 int result = pthread_mutex_lock( &m_mutex);
259 if( result == EDEADLK) {
264 AcquireSRWLockExclusive( &m_srwlock);
275#ifndef MI_PLATFORM_WINDOWS
276 int result = pthread_mutex_trylock( &m_mutex);
279 mi_base_assert( result == 0 || result == EBUSY || result == EDEADLK);
282 BOOL result = TryAcquireSRWLockExclusive( &m_srwlock);
286 ReleaseSRWLockExclusive( &m_srwlock);
296#ifndef MI_PLATFORM_WINDOWS
297 int result = pthread_mutex_unlock( &m_mutex);
303 ReleaseSRWLockExclusive( &m_srwlock);
337 if( m_lock && m_lock->try_lock())
352#ifndef MI_PLATFORM_WINDOWS
353 pthread_mutexattr_t mutex_attributes;
354 pthread_mutexattr_init( &mutex_attributes);
355 pthread_mutexattr_settype( &mutex_attributes,
PTHREAD_MUTEX_RECURSIVE);
356 pthread_mutex_init( &m_mutex, &mutex_attributes);
358 InitializeCriticalSection( &m_critical_section);
364#ifndef MI_PLATFORM_WINDOWS
365 int result = pthread_mutex_destroy( &m_mutex);
370 DeleteCriticalSection( &m_critical_section);
376#ifndef MI_PLATFORM_WINDOWS
377 int result = pthread_mutex_lock( &m_mutex);
382 EnterCriticalSection( &m_critical_section);
388#ifndef MI_PLATFORM_WINDOWS
389 int result = pthread_mutex_trylock( &m_mutex);
393 BOOL result = TryEnterCriticalSection( &m_critical_section);
400#ifndef MI_PLATFORM_WINDOWS
401 int result = pthread_mutex_unlock( &m_mutex);
405 LeaveCriticalSection( &m_critical_section);
439 if( m_lock && m_lock->try_lock())
Assertions and compile-time assertions.
Utility class to acquire a lock that is released by the destructor.
Definition: lock.h:61
Non-recursive lock class.
Definition: lock.h:49
Utility class to acquire a lock that is released by the destructor.
Definition: lock.h:155
Recursive lock class.
Definition: lock.h:143
Configuration of the Base API.
#define mi_base_assert(expr)
Base API assertion macro (without message).
Definition: assert.h:86
void set(Lock *lock)
Acquires a lock.
void set(Recursive_lock *lock)
Acquires a lock.
void lock()
Locks the lock.
Recursive_lock()
Constructor.
void release()
Releases the lock.
Block(Recursive_lock *lock=0)
Constructor.
void unlock()
Unlocks the lock.
bool try_set(Lock *lock)
Tries to acquire a lock.
bool try_set(Recursive_lock *lock)
Tries to acquire a lock.
void unlock()
Unlocks the lock.
Block(Lock *lock=0)
Constructor.
bool try_lock()
Tries to lock the lock.
void release()
Releases the lock.
bool try_lock()
Tries to lock the lock.
void lock()
Locks the lock.
~Recursive_lock()
Destructor.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: base.h:34