You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some C/C++ compilers are not implementing all of C++11 and above standard, it's often lacking the concurrency features that the standard brings. These compilers will at some point be updated. I was therefore looking for a way to reduce the effort of switching from a specific implementation to the C++11 standard one.
Copy file name to clipboardExpand all lines: include/pthread/mutex.hpp
+31-15Lines changed: 31 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -38,44 +38,60 @@ namespace pthread {
38
38
friendclasscondition_variable;
39
39
40
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.
41
+
/** Lock the mutex.
42
+
*
43
+
* The mutex object is locked (by calling pthread_mutex_lock). If the mutex is already locked, the calling thread blocks until the mutex becomes
44
+
* available. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner.
45
+
*
46
+
* @throw mutex_exception if error conditions preventing this method to succeed.
47
+
* @see unlock
48
+
* @see pthread_mutex_lock
45
49
*/
46
50
voidlock();
47
51
48
-
/**
52
+
/** Try to lock the mutex.
53
+
*
49
54
* Identical to lock method except that if the mutex object is currently locked (by any thread, including the
50
55
* current thread), the call returns immediately.
51
56
*
52
57
* @return true if the mutex is locked, false is returned if the lock is held by some other thread.
53
58
* @throw mutex_exception if error conditions preventing this method to succeed.
54
59
* @see lock
55
60
* @see unlock
61
+
* @see pthread_mutex_trylock
56
62
*/
57
63
booltry_lock();
58
64
59
-
/**
60
-
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.
61
-
@throw mutex_exception if error conditions preventing this method to succeed.
65
+
/** Release the mutex.
66
+
*
67
+
* Releases the mutex object referenced by mutex. The manner in which a mutex is released is dependent upon the mutex's
68
+
* type attribute. If there are threads blocked on the mutex object referenced by mutex when unlock is called,
69
+
* resulting in the mutex becoming available, the scheduling policy is used to determine which thread shall acquire the mutex.
70
+
*
71
+
* @throw mutex_exception if error conditions preventing this method to succeed.
72
+
* @see pthread_mutex_unlock
62
73
*/
63
74
voidunlock();
64
75
65
-
/**
66
-
Constructor/Desctructor
67
-
@throw mutex_exception if error conditions preventing this method to succeed.
76
+
/** create and initialize a mutex.
77
+
*
78
+
* > *WARN* the default mutex attributes are used.
79
+
*
80
+
* @throw mutex_exception if error conditions preventing this method to succeed.
81
+
* @see pthread_mutex_init
68
82
*/
69
83
mutex();
70
84
85
+
/** destroys the mutex.
86
+
*
87
+
* @see pthread_mutex_destroy
88
+
*/
89
+
virtual~mutex();
90
+
71
91
/** not copy-assignable, so no copy contructor is needed.
0 commit comments