aboutsummaryrefslogtreecommitdiff
path: root/src/stable/mutex.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/mutex.h94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/stable/mutex.h b/src/stable/mutex.h
index 1898118..23963e3 100644
--- a/src/stable/mutex.h
+++ b/src/stable/mutex.h
@@ -12,57 +12,57 @@
12 12
13namespace Bu 13namespace Bu
14{ 14{
15 /** 15 /**
16 * Simple mutex wrapper. Currently this doesn't do anything extra for you 16 * Simple mutex wrapper. Currently this doesn't do anything extra for you
17 * except keep all of the functionality together in an OO sorta' way and 17 * except keep all of the functionality together in an OO sorta' way and
18 * keep you from having to worry about cleaning up your mutexes properly, 18 * keep you from having to worry about cleaning up your mutexes properly,
19 * or initing them. 19 * or initing them.
20 *@ingroup Threading 20 *@ingroup Threading
21 */ 21 */
22 class Mutex 22 class Mutex
23 { 23 {
24 public: 24 public:
25 /** 25 /**
26 * Create an unlocked mutex. 26 * Create an unlocked mutex.
27 */ 27 */
28 Mutex(); 28 Mutex();
29 29
30 /** 30 /**
31 * Destroy a mutex. This can only be done when a mutex is unlocked. 31 * Destroy a mutex. This can only be done when a mutex is unlocked.
32 * Failure to unlock before destroying a mutex object could cause it to 32 * Failure to unlock before destroying a mutex object could cause it to
33 * wait for the mutex to unlock, the odds of which are usually farily 33 * wait for the mutex to unlock, the odds of which are usually farily
34 * low at deconstruction time. 34 * low at deconstruction time.
35 */ 35 */
36 ~Mutex(); 36 ~Mutex();
37 37
38 /** 38 /**
39 * Lock the mutex. This causes all future calls to lock on this 39 * Lock the mutex. This causes all future calls to lock on this
40 * instance of mutex to block until the first thread that called mutex 40 * instance of mutex to block until the first thread that called mutex
41 * unlocks it. At that point the next thread that called lock will get 41 * unlocks it. At that point the next thread that called lock will get
42 * a chance to go to work. Because of the nature of a mutex lock it is 42 * a chance to go to work. Because of the nature of a mutex lock it is
43 * a very bad idea to do any kind of serious or rather time consuming 43 * a very bad idea to do any kind of serious or rather time consuming
44 * computation within a locked section. This can cause thread-deadlock 44 * computation within a locked section. This can cause thread-deadlock
45 * and your program may hang. 45 * and your program may hang.
46 */ 46 */
47 int lock(); 47 int lock();
48 48
49 /** 49 /**
50 * Unlock the mutex. This allows the next thread that asked for a lock 50 * Unlock the mutex. This allows the next thread that asked for a lock
51 * to lock the mutex and continue with execution. 51 * to lock the mutex and continue with execution.
52 */ 52 */
53 int unlock(); 53 int unlock();
54 54
55 /** 55 /**
56 * Try to lock the mutex. This is the option to go with if you cannot 56 * Try to lock the mutex. This is the option to go with if you cannot
57 * avoid putting lengthy operations within a locked section. trylock 57 * avoid putting lengthy operations within a locked section. trylock
58 * will attempt to lock the mutex, if the mutex is already locked this 58 * will attempt to lock the mutex, if the mutex is already locked this
59 * function returns immediately with an error code. 59 * function returns immediately with an error code.
60 */ 60 */
61 int trylock(); 61 int trylock();
62 62
63 protected: 63 protected:
64 pthread_mutex_t mutex; /**< The internal mutex reference. */ 64 pthread_mutex_t mutex; /**< The internal mutex reference. */
65 }; 65 };
66} 66}
67 67
68#endif 68#endif