1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/thread/Mutex.h
11 #ifndef ZYPP_THREAD_MUTEX_H
12 #define ZYPP_THREAD_MUTEX_H
14 #include "zypp/base/NonCopyable.h"
15 #include "zypp/thread/MutexException.h"
18 //////////////////////////////////////////////////////////////////////
20 { ////////////////////////////////////////////////////////////////////
21 ////////////////////////////////////////////////////////////////////
23 { //////////////////////////////////////////////////////////////////
26 typedef pthread_mutex_t RecursiveMutex_t;
29 ////////////////////////////////////////////////////////////////
33 /** A recursive Mutex.
35 class Mutex: public zypp::base::NonCopyable
38 /** Create a new recursive Mutex object.
39 * \throws MutexException on initialization failure.
43 /** Destroys this Mutex object.
47 /** Acquire ownership of this Mutex object.
48 * This call will block if another thread has ownership of
49 * this Mutex. When it returns, the current thread is the
50 * owner of this Mutex object.
52 * In the same thread, this recursive mutex can be acquired
55 * \throws MutexException if the maximum number of recursive
56 * locks for mutex has been exceeded.
60 /** Release ownership of this Mutex object.
61 * If another thread is waiting to acquire the ownership of
62 * this mutex it will stop blocking and acquire ownership
63 * when this call returns.
65 * \throws MutexException if the current thread does not
70 /** Try to acquire ownership of this Mutex object.
71 * This call will return false if another thread has ownership
72 * of this Mutex or the maximum number of recursive locks for
73 * mutex has been exceeded.
74 * When it returns true, the current thread is the owner of
77 * \return true, if ownership was acquired.
82 RecursiveMutex_t m_mutex;
86 //////////////////////////////////////////////////////////////////
88 ////////////////////////////////////////////////////////////////////
89 ////////////////////////////////////////////////////////////////////
91 //////////////////////////////////////////////////////////////////////
93 #endif // ZYPP_THREAD_MUTEX_H
95 ** vim: set ts=2 sts=2 sw=2 ai et: