27 pthread_mutexattr_t
attr;
29 int ret = pthread_mutexattr_init(&attr);
33 _(
"Can't initialize mutex attributes"));
36 ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
40 _(
"Can't set recursive mutex attribute"));
43 ret = pthread_mutex_init(&
m_mutex, &attr);
47 _(
"Can't initialize recursive mutex"));
54 if( pthread_mutex_destroy(&
m_mutex) != 0 && errno == EBUSY)
57 if( pthread_mutex_unlock(&
m_mutex) == 0)
59 pthread_mutex_destroy(&
m_mutex);
74 if( pthread_mutex_lock(&
m_mutex) != 0)
77 _(
"Can't acquire the mutex lock"));
84 if( pthread_mutex_unlock(&
m_mutex) != 0)
87 _(
"Can't release the mutex lock"));
94 return (pthread_mutex_trylock(&
m_mutex) == 0);
bool trylock()
Try to acquire ownership of this Mutex object.
Exception type thrown on mutex errors.
#define ZYPP_THROW_ERRNO_MSG(EXCPTTYPE, MSG)
Throw Exception built from errno and a message string.
#define _(MSG)
Return translated text.
void lock()
Acquire ownership of this Mutex object.
Mutex()
Create a new recursive Mutex object.
void unlock()
Release ownership of this Mutex object.
~Mutex()
Destroys this Mutex object.