Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
LockScope.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_LockScope_h_ 00003 #define INCLUDED_LockScope_h_ 00004 00005 #include "MutexLock.h" 00006 #include "ProcessID.h" 00007 00008 //! Locks a MutexLock until the LockScope goes out of scope 00009 /*! This can help prevent forgetting to do it if you function has multiple return points */ 00010 template<unsigned int num_doors> 00011 class LockScope { 00012 public: 00013 //!constructor, locks @a lock with the current process's id (ProcessID::getID()) 00014 LockScope(MutexLock<num_doors>& lock) : l(lock) {l.lock(ProcessID::getID());} 00015 //!constructor, locks @a lock with @a id 00016 LockScope(MutexLock<num_doors>& lock, int id) : l(lock) {l.lock(id);} 00017 //!destructor, releases lock received in constructor 00018 ~LockScope() { l.unlock(); } 00019 protected: 00020 MutexLock<num_doors>& l; //!< the lock 00021 }; 00022 00023 /*! @file 00024 * @brief Defines LockScope, which locks a MutexLock until the LockScope goes out of scope 00025 * @author ejt (Creator) 00026 * 00027 * $Author: ejt $ 00028 * $Name: tekkotsu-2_4_1 $ 00029 * $Revision: 1.2 $ 00030 * $State: Exp $ 00031 * $Date: 2005/06/01 05:47:46 $ 00032 */ 00033 00034 #endif |
Tekkotsu v2.4.1 |
Generated Tue Aug 16 16:32:47 2005 by Doxygen 1.4.4 |