Homepage Demos Overview Downloads Tutorials Reference
Credits

LockScope.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_LockScope_h_
00003 #define INCLUDED_LockScope_h_
00004 
00005 #include "Shared/MutexLock.h"
00006 
00007 //! Locks a MutexLock until the LockScope goes out of scope
00008 /*! This can help prevent forgetting to do it if you function has multiple return points */
00009 template<unsigned int num_doors>
00010 class LockScope {
00011 public:
00012   //!constructor, locks @a lock with @a id
00013   LockScope(MutexLock<num_doors>& lock, int id) : l(lock) {l.lock(id);}
00014   //!destructor, releases lock received in constructor
00015   ~LockScope() { l.release(); }
00016 protected:
00017   MutexLock<num_doors>& l; //!< the lock
00018 };
00019 
00020 /*! @file
00021  * @brief Defines LockScope, which locks a MutexLock until the LockScope goes out of scope
00022  * @author ejt (Creator)
00023  *
00024  * $Author: ejt $
00025  * $Name: tekkotsu-2_2_2 $
00026  * $Revision: 1.3 $
00027  * $State: Rel $
00028  * $Date: 2003/09/25 15:31:53 $
00029  */
00030 
00031 #endif

Tekkotsu v2.2.2
Generated Tue Jan 4 15:43:14 2005 by Doxygen 1.4.0