Skip to content

Commit 078ce34

Browse files
Merge branch '181-commenting' into develop
2 parents 009b9e3 + eb540e6 commit 078ce34

File tree

5 files changed

+268
-248
lines changed

5 files changed

+268
-248
lines changed

include/pthread/condition_variable.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ namespace pthread {
232232
* @throw condition_variable_exception if conditional variable failed to be destroyed (pthread_cond_destroy != 0)
233233
* @see pthread_cond_destroy
234234
*/
235-
~condition_variable() ;
235+
virtual ~condition_variable() ;
236236

237237
private:
238238

include/pthread/lock_guard.hpp

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,71 +15,74 @@
1515

1616
#include "pthread/mutex.hpp"
1717

18-
1918
namespace pthread {
2019

21-
/** \addtogroup concurrency
22-
*
23-
* @{
24-
*/
25-
26-
//class condition_variable ;
27-
28-
/**
29-
This class was designed to encapsulate a mutex and automatically control the lock attribute.
30-
31-
The lock_guard lock the associated mutex once we instanciate the class and the lock is automatically unlocked
32-
once the object is destroyed. This allow us to correlate the lock with the scope of the object.
33-
34-
@author herbert koelman
35-
*/
36-
template<class MutexType>
37-
class lock_guard {
38-
39-
friend class condition_variable;
40-
41-
public:
42-
/**
43-
* The constructor is forced to only accept a mutex object or any object of a subclass.
20+
/** \addtogroup concurrency
4421
*
45-
* The mutex is locked up upon completion.
46-
*
47-
* @param m reference to a valid pthread::mutex
48-
*/
49-
explicit lock_guard(MutexType &m){ //: _mutex(&m) {
50-
_mutex = &m ;
51-
_mutex->lock();
52-
}
53-
54-
/** The destructor release the guarded mutex.
22+
* @{
5523
*/
56-
~lock_guard() {
57-
_mutex->unlock();
58-
}
5924

6025
/**
61-
* Cannot be copied.
62-
*/
63-
lock_guard( const lock_guard &) = delete;
64-
65-
/** @return a const reference to the guarded mutex
26+
* This class was designed to encapsulate a mutex and automatically control the lock attribute.
6627
*
67-
* @deprecated condition_variable is now a friend class
68-
*/
69-
MutexType *internal_mutex() {
70-
return _mutex ;
71-
}
72-
73-
/**
74-
Desabling the = operator.
28+
* The lock_guard lock the associated mutex once we instanciate the class and the lock is automatically unlocked
29+
* once the object is destroyed. This allow us to correlate the lock with the scope of the object.
30+
*
31+
* > *WARN* this is a wrapper and therefore doesn't deal with allocating/deallocating the mutex it is guarding.
32+
*
33+
* @author herbert koelman
34+
* @tparam MutexType a kind of mutex
7535
*/
76-
void operator=(lock_guard &) = delete;
77-
78-
private:
79-
MutexType *_mutex;
80-
};
81-
82-
/** @} */
36+
template<class MutexType>
37+
class lock_guard {
38+
39+
friend class condition_variable;
40+
41+
public:
42+
/**
43+
* The constructor is forced to only accept a mutex object or any object of a subclass.
44+
*
45+
* > *WARN* The mutex is locked up upon completion.
46+
*
47+
* @param mutex reference to a valid mutex type.
48+
* @see mutex#lock
49+
*/
50+
explicit lock_guard(MutexType &mutex) { //: _mutex(&m) {
51+
_mutex = &mutex;
52+
_mutex->lock();
53+
}
54+
55+
/** The destructor release the guarded mutex.
56+
*
57+
* @see mutex#unlock
58+
*/
59+
~lock_guard() {
60+
_mutex->unlock();
61+
}
62+
63+
/** @return a const reference to the guarded mutex
64+
*
65+
* @deprecated condition_variable is now a friend class
66+
* @see condition_variable
67+
*/
68+
MutexType *internal_mutex() {
69+
return _mutex;
70+
}
71+
72+
/**Cannot be copied.
73+
*/
74+
lock_guard(const lock_guard &) = delete;
75+
76+
/**
77+
* Desabling the = operator.
78+
*/
79+
void operator=(lock_guard &) = delete;
80+
81+
private:
82+
MutexType *_mutex;
83+
};
84+
85+
/** @} */
8386
} // namespace pthread
8487

8588
#endif /* pthread_lock_guard_H */

0 commit comments

Comments
 (0)