MACE
1.0.0
|
00001 #ifndef MACE_CMT_MUTEX_HPP_ 00002 #define MACE_CMT_MUTEX_HPP_ 00003 #include <mace/cmt/spin_yield_lock.hpp> 00004 00005 namespace mace { namespace cmt { 00006 class thread; 00007 struct context; 00008 00090 class mutex { 00091 public: 00092 mutex(); 00093 ~mutex(); 00094 00095 bool try_lock(); 00096 bool timed_lock( const boost::system_time& abs_time); 00097 void lock(); 00098 void unlock(); 00099 00100 template<typename DurationType> 00101 bool timed_lock( const DurationType& rel_time ) { 00102 return timed_lock( boost::get_system_time() + rel_time ); 00103 } 00104 00105 private: 00106 cmt::spin_yield_lock m_blist_lock; 00107 cmt::context* m_blist; 00108 }; 00109 00110 } } 00111 00112 #endif // MACE_CMT_MUTEX_HPP_