]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STARLIGHT/starlight/include/slmutex.h~
STARLIGHT code and interface
[u/mrichter/AliRoot.git] / STARLIGHT / starlight / include / slmutex.h~
diff --git a/STARLIGHT/starlight/include/slmutex.h~ b/STARLIGHT/starlight/include/slmutex.h~
new file mode 100644 (file)
index 0000000..0035392
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef SLMUTEX_H
+#define SLMUTEX_H
+
+#include <pthread.h>
+
+class MutexPosix
+{
+private:
+  MutexPosix(const MutexPosix &);
+  
+  pthread_mutex_t _mutex;
+  
+public:
+  MutexPosix() {}
+  int lock() { return pthread_mutex_lock(&_mutex); }
+  int unlock() { return pthread_mutex_unlock(&_mutex); }
+  
+};
+
+template<typename M>
+class Lockguard
+{
+private:
+  
+  M *_mutex;
+  Lockguard(const Lockguard & guard); // Do not implement
+public:
+  
+  Lockguard(M *mutex): _mutex(mutex) {_mutex->lock();}
+  ~Lockguard() { _mutex->unlock(); }
+  
+};
+
+#endif
\ No newline at end of file