|
21 | 21 |
|
22 | 22 | namespace pthread { |
23 | 23 |
|
24 | | - /** \addtogroup concurrency |
25 | | - * |
26 | | - * @{ |
27 | | - */ |
28 | | - class condition_variable; |
29 | | - |
30 | | - /** The mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads. |
31 | | - * |
32 | | - * @author herbert koelman |
33 | | - * @date 18/3/2016 |
34 | | - */ |
35 | | - class mutex { |
36 | | - |
37 | | - friend class condition_variable; |
38 | | - |
39 | | - public: |
40 | | - /** |
41 | | - The mutex object is locked (by calling pthread_mutex_lock). If the mutex is already locked, the calling thread blocks until the mutex becomes |
42 | | - available. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner. |
43 | | - @throw mutex_exception if error conditions preventing this method to succeed. |
| 24 | + /** \addtogroup concurrency |
| 25 | + * |
| 26 | + * @{ |
44 | 27 | */ |
45 | | - void lock (); |
46 | 28 |
|
47 | | - /** |
48 | | - The function pthread_mutex_trylock is identical to pthread_mutex_lock except tha |
49 | | - if the mutex object referenced by mutex is currently locked (by any thread, |
50 | | - including the current thread), the call returns immediately. |
| 29 | + class condition_variable; |
51 | 30 |
|
52 | | - @throw mutex_exception if error conditions preventing this method to succeed. |
53 | | - @see lock |
| 31 | + /** The mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads. |
| 32 | + * |
| 33 | + * @author herbert koelman |
| 34 | + * @date 18/3/2016 |
54 | 35 | */ |
55 | | - void try_lock (); |
56 | | - |
57 | | - /** |
58 | | - The pthread_mutex_unlock function releases the mutex object referenced by mutex. The manner in which a mutex is released is dependent upon the mutex's type attribute. If there are threads blocked on the mutex object referenced by mutex when unlock is called, resulting in the mutex becoming available, the scheduling policy is used to determine which thread shall acquire the mutex. |
59 | | - @throw mutex_exception if error conditions preventing this method to succeed. |
60 | | - */ |
61 | | - void unlock (); |
62 | | - |
63 | | - /* |
64 | | - Constructor/Desctructor |
65 | | - @throw mutex_exception if error conditions preventing this method to succeed. |
66 | | - */ |
67 | | - mutex (); |
68 | | - virtual ~mutex (); |
69 | | - |
70 | | - protected: |
71 | | - /** pthread mutex structure */ |
72 | | - pthread_mutex_t _mutex; |
73 | | - }; |
74 | | - |
75 | | - /** @} */ |
| 36 | + class mutex { |
| 37 | + |
| 38 | + friend class condition_variable; |
| 39 | + |
| 40 | + public: |
| 41 | + /** |
| 42 | + The mutex object is locked (by calling pthread_mutex_lock). If the mutex is already locked, the calling thread blocks until the mutex becomes |
| 43 | + available. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner. |
| 44 | + @throw mutex_exception if error conditions preventing this method to succeed. |
| 45 | + */ |
| 46 | + void lock(); |
| 47 | + |
| 48 | + /** |
| 49 | + The function pthread_mutex_trylock is identical to pthread_mutex_lock except tha |
| 50 | + if the mutex object referenced by mutex is currently locked (by any thread, |
| 51 | + including the current thread), the call returns immediately. |
| 52 | +
|
| 53 | + @throw mutex_exception if error conditions preventing this method to succeed. |
| 54 | + @see lock |
| 55 | + */ |
| 56 | + void try_lock(); |
| 57 | + |
| 58 | + /** |
| 59 | + The pthread_mutex_unlock function releases the mutex object referenced by mutex. The manner in which a mutex is released is dependent upon the mutex's type attribute. If there are threads blocked on the mutex object referenced by mutex when unlock is called, resulting in the mutex becoming available, the scheduling policy is used to determine which thread shall acquire the mutex. |
| 60 | + @throw mutex_exception if error conditions preventing this method to succeed. |
| 61 | + */ |
| 62 | + void unlock(); |
| 63 | + |
| 64 | + /** |
| 65 | + Constructor/Desctructor |
| 66 | + @throw mutex_exception if error conditions preventing this method to succeed. |
| 67 | + */ |
| 68 | + mutex(); |
| 69 | + |
| 70 | + /** not copy-assignable, so no copy contructor is needed. |
| 71 | + * |
| 72 | + */ |
| 73 | + mutex(const mutex &) = delete; |
| 74 | + /** |
| 75 | + * destroys the mutes (pthread_mutex_destroy) |
| 76 | + */ |
| 77 | + virtual ~mutex(); |
| 78 | + |
| 79 | + /** not copy-assignable |
| 80 | + * |
| 81 | + */ |
| 82 | + void operator=(const mutex &) = delete; |
| 83 | + |
| 84 | + protected: |
| 85 | + /** pthread mutex structure */ |
| 86 | + pthread_mutex_t _mutex; |
| 87 | + }; |
| 88 | + |
| 89 | + /** @} */ |
76 | 90 |
|
77 | 91 | } // namespace pthread |
78 | 92 |
|
|
0 commit comments