aboutsummaryrefslogtreecommitdiff
path: root/dep/src/zthread/solaris/FastRecursiveLock.h
diff options
context:
space:
mode:
authormegamage <none@none>2009-02-12 17:09:15 -0600
committermegamage <none@none>2009-02-12 17:09:15 -0600
commit6aee5fcbe7473a3cbac12b7e8482a7b98bef8be3 (patch)
tree91ec91d5c19eba9c2fe0e84b1c9dc7047a3de80e /dep/src/zthread/solaris/FastRecursiveLock.h
parent2d2f433b4de1c35b22aaf07854fc0ee11fcb350d (diff)
parentf385747164c3fb278c92ef46fbd6c3da6590bbf0 (diff)
*Merge.
--HG-- branch : trunk
Diffstat (limited to 'dep/src/zthread/solaris/FastRecursiveLock.h')
-rw-r--r--dep/src/zthread/solaris/FastRecursiveLock.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/dep/src/zthread/solaris/FastRecursiveLock.h b/dep/src/zthread/solaris/FastRecursiveLock.h
index 956e1dbd3ad..2de0f8cd022 100644
--- a/dep/src/zthread/solaris/FastRecursiveLock.h
+++ b/dep/src/zthread/solaris/FastRecursiveLock.h
@@ -35,13 +35,13 @@ namespace ZThread {
* @date <2003-07-16T23:31:23-0400>
* @version 2.2.0
*
- * This FastRecursiveLock implementation uses pthreads mutex attribute
- * functions to create a recursive lock. This implementation is not
- * specific to solaris and will work on any system that supports
- * pthread_mutexattr_settype().
- */
+ * This FastRecursiveLock implementation uses pthreads mutex attribute
+ * functions to create a recursive lock. This implementation is not
+ * specific to solaris and will work on any system that supports
+ * pthread_mutexattr_settype().
+ */
class FastRecursiveLock : private NonCopyable {
-
+
pthread_mutex_t _mtx;
/**
@@ -50,7 +50,7 @@ class FastRecursiveLock : private NonCopyable {
* Utility class to maintain the attribute as long as it is needed.
*/
class Attribute {
-
+
pthread_mutexattr_t _attr;
public:
@@ -60,13 +60,13 @@ class FastRecursiveLock : private NonCopyable {
if(pthread_mutexattr_init(&_attr) != 0) {
assert(0);
}
-
+
if(pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE) != 0) {
assert(0);
}
}
-
+
~Attribute() {
if(pthread_mutexattr_destroy(&_attr) != 0) {
@@ -84,36 +84,36 @@ class FastRecursiveLock : private NonCopyable {
public:
inline FastRecursiveLock() {
-
+
static Attribute attr;
pthread_mutex_init(&_mtx, (pthread_mutexattr_t*)attr);
}
-
+
inline ~FastRecursiveLock() {
pthread_mutex_destroy(&_mtx);
}
-
+
inline void acquire() {
-
+
pthread_mutex_lock(&_mtx);
}
inline void release() {
-
+
pthread_mutex_unlock(&_mtx);
-
+
}
-
+
inline bool tryAcquire(unsigned long timeout=0) {
return (pthread_mutex_trylock(&_mtx) == 0);
}
-
+
}; /* FastRecursiveLock */