From 518accb0c8ce5330008c796c24cfec8fcd309ef6 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Sat, 6 Jul 2013 19:35:38 +0200 Subject: [PATCH] init pthread_mutexattr_t in Mutex.cpp --- src/Mutex.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Mutex.cpp b/src/Mutex.cpp index fc19966..94e93b2 100644 --- a/src/Mutex.cpp +++ b/src/Mutex.cpp @@ -12,16 +12,22 @@ namespace { return mutex; } + pthread_mutexattr_t& AttrCtor( pthread_mutexattr_t& attr ) + { + pthread_mutexattr_init( &attr ); + return attr; + } + } // anonym namespace Mutex::Mutex( MutexType type ) - : m_mutex( MutexCtor( m_mutex ) ) // init with function + : m_mutex( MutexCtor( m_mutex ) ) , m_type( type ) + , m_attr( AttrCtor( m_attr ) ) { TRACE; - if ( type != PTHREAD_MUTEX_DEFAULT ) { - pthread_mutexattr_init( &m_attr ); + if ( (int)type != PTHREAD_MUTEX_DEFAULT ) { pthread_mutexattr_settype( &m_attr, type ); pthread_mutex_init( &m_mutex, &m_attr ); }