init pthread_mutexattr_t in Mutex.cpp

master
Denes Matetelki 12 years ago
parent 6ee6b66953
commit 518accb0c8

@ -12,16 +12,22 @@ namespace {
return mutex; return mutex;
} }
pthread_mutexattr_t& AttrCtor( pthread_mutexattr_t& attr )
{
pthread_mutexattr_init( &attr );
return attr;
}
} // anonym namespace } // anonym namespace
Mutex::Mutex( MutexType type ) Mutex::Mutex( MutexType type )
: m_mutex( MutexCtor( m_mutex ) ) // init with function : m_mutex( MutexCtor( m_mutex ) )
, m_type( type ) , m_type( type )
, m_attr( AttrCtor( m_attr ) )
{ {
TRACE; TRACE;
if ( type != PTHREAD_MUTEX_DEFAULT ) { if ( (int)type != PTHREAD_MUTEX_DEFAULT ) {
pthread_mutexattr_init( &m_attr );
pthread_mutexattr_settype( &m_attr, type ); pthread_mutexattr_settype( &m_attr, type );
pthread_mutex_init( &m_mutex, &m_attr ); pthread_mutex_init( &m_mutex, &m_attr );
} }

Loading…
Cancel
Save