Libbarrett  1.2.4
include/barrett/thread/null_mutex.h
00001 /*
00002  * null_mutex.h
00003  *
00004  *  Created on: Dec 15, 2009
00005  *      Author: dc
00006  */
00007 
00008 #ifndef BARRETT_THREAD_NULL_MUTEX_H_
00009 #define BARRETT_THREAD_NULL_MUTEX_H_
00010 
00011 
00012 #include <barrett/detail/ca_macro.h>
00013 #include <barrett/thread/abstract/mutex.h>
00014 
00015 
00016 namespace barrett {
00017 namespace thread {
00018 
00019 
00020 // provides no synchronization or mutual exclusion
00021 class NullMutex : public Mutex {
00022 public:
00023         // since all NullMutex's are the same, feel free to give out references to this object if you just need to return a NullMutex...
00024         static NullMutex aNullMutex;
00025 
00026         NullMutex() {}
00027         virtual ~NullMutex() {}
00028 
00029         virtual void lock() {}
00030         virtual bool try_lock() {  return true;  }
00031         virtual void unlock() {}
00032 
00033         virtual int fullUnlock() { return 0; }
00034         virtual void relock(int lc) {}
00035 
00036 private:
00037         DISALLOW_COPY_AND_ASSIGN(NullMutex);
00038 };
00039 
00040 
00041 }
00042 }
00043 
00044 
00045 #endif /* BARRETT_THREAD_NULL_MUTEX_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines