aboutsummaryrefslogtreecommitdiff
path: root/src/itomutex.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-10-06 03:25:22 +0000
committerMike Buland <eichlan@xagasoft.com>2011-10-06 03:25:22 +0000
commit208b983734d7431699f4bd3534e08321e42ada86 (patch)
treea6865f0db36e9c3b8dd13b9ed4d10d282f0f7cbf /src/itomutex.h
parent1358cb4c7325e01c13533ca402cccc28575cdf14 (diff)
downloadlibbu++-208b983734d7431699f4bd3534e08321e42ada86.tar.gz
libbu++-208b983734d7431699f4bd3534e08321e42ada86.tar.bz2
libbu++-208b983734d7431699f4bd3534e08321e42ada86.tar.xz
libbu++-208b983734d7431699f4bd3534e08321e42ada86.zip
Renamed most of the core threading system, some ancillary systems need some
kind of prefix or something, we could stick with Ito, I will until I think of something else.
Diffstat (limited to 'src/itomutex.h')
-rw-r--r--src/itomutex.h68
1 files changed, 0 insertions, 68 deletions
diff --git a/src/itomutex.h b/src/itomutex.h
deleted file mode 100644
index 68a0c1d..0000000
--- a/src/itomutex.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_ITO_MUTEX_H
9#define BU_ITO_MUTEX_H
10
11#include <pthread.h>
12
13namespace Bu
14{
15 /**
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
18 * keep you from having to worry about cleaning up your mutexes properly,
19 * or initing them.
20 *@ingroup Threading
21 */
22 class ItoMutex
23 {
24 public:
25 /**
26 * Create an unlocked mutex.
27 */
28 ItoMutex();
29
30 /**
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
33 * wait for the mutex to unlock, the odds of which are usually farily
34 * low at deconstruction time.
35 */
36 ~ItoMutex();
37
38 /**
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
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
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
45 * and your program may hang.
46 */
47 int lock();
48
49 /**
50 * Unlock the mutex. This allows the next thread that asked for a lock
51 * to lock the mutex and continue with execution.
52 */
53 int unlock();
54
55 /**
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
58 * will attempt to lock the mutex, if the mutex is already locked this
59 * function returns immediately with an error code.
60 */
61 int trylock();
62
63 protected:
64 pthread_mutex_t mutex; /**< The internal mutex reference. */
65 };
66}
67
68#endif