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