aboutsummaryrefslogtreecommitdiff
path: root/dep/include/zthread/Guard.h
diff options
context:
space:
mode:
authorParadox <none@none>2009-02-09 08:16:34 -0500
committerParadox <none@none>2009-02-09 08:16:34 -0500
commitd230302b16474ff22a35243ffed6236ef4fc7fb9 (patch)
treee3679ad841a47b275756f2721f9aa24a3ee548a6 /dep/include/zthread/Guard.h
parentb0694d7e5e794b361fa178d55fefdb98cf47e9ca (diff)
Replace tabs with spaces in more files.
--HG-- branch : trunk
Diffstat (limited to 'dep/include/zthread/Guard.h')
-rw-r--r--dep/include/zthread/Guard.h96
1 files changed, 48 insertions, 48 deletions
diff --git a/dep/include/zthread/Guard.h b/dep/include/zthread/Guard.h
index 988c3cfa3c2..d1befccd85a 100644
--- a/dep/include/zthread/Guard.h
+++ b/dep/include/zthread/Guard.h
@@ -26,15 +26,15 @@
#include "zthread/NonCopyable.h"
#include "zthread/Exceptions.h"
-namespace ZThread {
+namespace ZThread {
-//
-// GuardLockingPolicyContract {
//
-// createScope(lock_type&)
-// bool createScope(lock_type&, unsigned long)
-// destroyScope(lock_type&)
-//
+// GuardLockingPolicyContract {
+//
+// createScope(lock_type&)
+// bool createScope(lock_type&, unsigned long)
+// destroyScope(lock_type&)
+//
// }
//
@@ -59,12 +59,12 @@ class LockHolder {
template <class T>
LockHolder(T& t) : _lock(extract(t)._lock), _enabled(true) { }
-
+
LockHolder(LockHolder& holder) : _lock(holder._lock), _enabled(true) { }
LockHolder(LockType& lock) : _lock(lock), _enabled(true) { }
- void disable() {
+ void disable() {
_enabled = false;
}
@@ -78,7 +78,7 @@ class LockHolder {
protected:
- template <class T>
+ template <class T>
static LockHolder& extract(T& t) {
// Design and Evolution of C++, page 328
return (LockHolder&)(t);
@@ -117,7 +117,7 @@ class CompoundScope {
return false;
}
-
+
return true;
}
@@ -154,7 +154,7 @@ class LockedScope {
* @param lock2 LockType1& is the LockHolder that wants to share
template <class LockType1, class LockType2>
static void shareScope(LockHolder<LockType1>& l1, LockHolder<LockType2>& l2) {
-
+
l2.getLock().acquire();
}
@@ -207,7 +207,7 @@ class LockedScope {
*
* Locking policy for Lockable objects. This policy release()s a Lockable
* when the protection scope is created, and it acquire()s a Lockable
- * when the scope is destroyed.
+ * when the scope is destroyed.
*/
class UnlockedScope {
public:
@@ -251,7 +251,7 @@ class UnlockedScope {
}
};
-
+
/**
@@ -277,7 +277,7 @@ class TimedLockedScope {
if(!l2.getLock().tryAcquire(TimeOut))
throw Timeout_Exception();
-
+
}
template <class LockType>
@@ -338,29 +338,29 @@ class OverlappedScope {
* @version 2.2.0
*
* Scoped locking utility. This template class can be given a Lockable
- * synchronization object and can 'Guard' or serialize access to
+ * synchronization object and can 'Guard' or serialize access to
* that method.
- *
- * For instance, consider a case in which a class or program have a
- * Mutex object associated with it. Access can be serialized with a
+ *
+ * For instance, consider a case in which a class or program have a
+ * Mutex object associated with it. Access can be serialized with a
* Guard as shown below.
*
* @code
*
* Mutex _mtx;
* void guarded() {
- *
+ *
* Guard<Mutex> g(_mtx);
*
* }
*
* @endcode
*
- * The Guard will lock the synchronization object when it is created and
- * automatically unlock it when it goes out of scope. This eliminates
+ * The Guard will lock the synchronization object when it is created and
+ * automatically unlock it when it goes out of scope. This eliminates
* common mistakes like forgetting to unlock your mutex.
*
- * An alternative to the above example would be
+ * An alternative to the above example would be
*
* @code
*
@@ -385,15 +385,15 @@ class Guard : private LockHolder<LockType>, private NonCopyable {
friend class LockHolder<LockType>;
public:
-
+
/**
* Create a Guard that enforces a the effective protection scope
- * throughout the lifetime of the Guard object or until the protection
+ * throughout the lifetime of the Guard object or until the protection
* scope is modified by another Guard.
*
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
- * @post the protection scope may be ended prematurely
+ * @post the protection scope may be ended prematurely
*/
Guard(LockType& lock) : LockHolder<LockType>(lock) {
@@ -403,12 +403,12 @@ public:
/**
* Create a Guard that enforces a the effective protection scope
- * throughout the lifetime of the Guard object or until the protection
+ * throughout the lifetime of the Guard object or until the protection
* scope is modified by another Guard.
*
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
- * @post the protection scope may be ended prematurely
+ * @post the protection scope may be ended prematurely
*/
Guard(LockType& lock, unsigned long timeout) : LockHolder<LockType>(lock) {
@@ -419,31 +419,31 @@ public:
/**
* Create a Guard that shares the effective protection scope
- * from the given Guard to this Guard.
+ * from the given Guard to this Guard.
*
- * @param g Guard<U, V> guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard<U, V> guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
template <class U, class V>
Guard(Guard<U, V>& g) : LockHolder<LockType>(g) {
LockingPolicy::shareScope(*this, extract(g));
-
+
}
/**
* Create a Guard that shares the effective protection scope
- * from the given Guard to this Guard.
+ * from the given Guard to this Guard.
*
- * @param g Guard guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
Guard(Guard& g) : LockHolder<LockType>(g) {
LockingPolicy::shareScope(*this, g);
-
+
}
@@ -451,8 +451,8 @@ public:
* Create a Guard that transfers the effective protection scope
* from the given Guard to this Guard.
*
- * @param g Guard<U, V> guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard<U, V> guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
template <class U, class V>
@@ -467,8 +467,8 @@ public:
* Create a Guard that transfers the effective protection scope
* from the given Guard to this Guard.
*
- * @param g Guard guard that is currently enabled
- * @param lock LockType the lock this Guard will use to enforce its
+ * @param g Guard guard that is currently enabled
+ * @param lock LockType the lock this Guard will use to enforce its
* protection scope.
*/
Guard(Guard& g, LockType& lock) : LockHolder<LockType>(lock) {
@@ -476,7 +476,7 @@ public:
LockingPolicy::transferScope(*this, g);
}
-
+
/**
* Unlock a given Lockable object with the destruction of this Guard
@@ -488,14 +488,14 @@ public:
template <class LockType, class LockingPolicy>
Guard<LockType, LockingPolicy>::~Guard() throw() {
-
+
try {
-
+
if(!this->isDisabled())
LockingPolicy::destroyScope(*this);
-
- } catch (...) { /* ignore */ }
-
+
+ } catch (...) { /* ignore */ }
+
}