18#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
36 class Mutex::MutexImpl
45 MutexImpl(
const MutexImpl& );
46 MutexImpl& operator=(
const MutexImpl& );
48#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
49 CRITICAL_SECTION m_cs;
50#elif defined( HAVE_PTHREAD )
51 pthread_mutex_t m_mutex;
56 Mutex::MutexImpl::MutexImpl()
58#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
61 InitializeCriticalSection( &m_cs );
62#elif defined( HAVE_PTHREAD )
65 pthread_mutexattr_t mutexAttribute;
66 pthread_mutexattr_init( &mutexAttribute );
67 pthread_mutexattr_settype( &mutexAttribute, PTHREAD_MUTEX_RECURSIVE );
68 pthread_mutex_init( &m_mutex, &mutexAttribute );
69 pthread_mutexattr_destroy( &mutexAttribute );
73 Mutex::MutexImpl::~MutexImpl()
75#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
76 DeleteCriticalSection( &m_cs );
77#elif defined( HAVE_PTHREAD )
78 pthread_mutex_destroy( &m_mutex );
82 void Mutex::MutexImpl::lock()
84#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
85 EnterCriticalSection( &m_cs );
86#elif defined( HAVE_PTHREAD )
87 pthread_mutex_lock( &m_mutex );
91 bool Mutex::MutexImpl::trylock()
93#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
94 return TryEnterCriticalSection( &m_cs ) ? true :
false;
95#elif defined( HAVE_PTHREAD )
96 return !( pthread_mutex_trylock( &m_mutex ) );
102 void Mutex::MutexImpl::unlock()
104#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
105 LeaveCriticalSection( &m_cs );
106#elif defined( HAVE_PTHREAD )
107 pthread_mutex_unlock( &m_mutex );
112 : m_mutex( new MutexImpl() )
128 return m_mutex->trylock();
The namespace for the gloox library.