Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

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-1_4_1 $
00026  * $Revision: 1.2 $
00027  * $State: Exp $
00028  * $Date: 2003/04/06 20:57:45 $
00029  */
00030 
00031 #endif

Tekkotsu v1.4
Generated Sat Jul 19 00:06:31 2003 by Doxygen 1.3.2