summaryrefslogtreecommitdiff
path: root/src/TNetLib/.svn/text-base/Mutex.h.svn-base
diff options
context:
space:
mode:
Diffstat (limited to 'src/TNetLib/.svn/text-base/Mutex.h.svn-base')
-rw-r--r--src/TNetLib/.svn/text-base/Mutex.h.svn-base34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/TNetLib/.svn/text-base/Mutex.h.svn-base b/src/TNetLib/.svn/text-base/Mutex.h.svn-base
new file mode 100644
index 0000000..ae2cfff
--- /dev/null
+++ b/src/TNetLib/.svn/text-base/Mutex.h.svn-base
@@ -0,0 +1,34 @@
+
+#include <pthread.h>
+
+namespace TNet {
+
+/**
+ * This class encapsulates mutex to ensure
+ * exclusive access to some critical section
+ * which manipulates shared resources.
+ *
+ * The mutex must be unlocked from the
+ * SAME THREAD which locked it
+ */
+class Mutex {
+ public:
+ Mutex();
+ ~Mutex();
+
+ void Lock();
+
+ /**
+ * Try to lock the mutex without waiting for it.
+ * Returns: true when lock successfull,
+ * false when mutex was already locked
+ */
+ bool TryLock();
+
+ void Unlock();
+
+ private:
+ pthread_mutex_t mutex_;
+};
+
+} //namespace TNet