Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

lock_guard.h

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #ifndef lock_guard_h
00004 #define lock_guard_h
00005 
00006 //
00007 // INTERFACE definition follows 
00008 //
00009 
00010 
00011 // 
00012 // Lock_guard: a guard object using a lock such as helping_lock_t
00013 // 
00014 template<typename LOCK>
00015 class Lock_guard
00016 {
00017   LOCK *_lock;
00018 
00019 public:  
00020   inline Lock_guard(LOCK *l);
00021   
00022   inline ~Lock_guard();
00023   
00024   inline bool was_set(void);
00025 };
00026 
00027 //
00028 // IMPLEMENTATION of inline functions (and needed classes)
00029 //
00030 
00031 
00032 
00033 
00034 template<typename LOCK> inline Lock_guard<LOCK>::Lock_guard(LOCK *l)
00035   : _lock(l)
00036 {
00037   if (_lock->test_and_set())
00038     _lock = 0;                  // Was locked already -- avoid unlock.
00039 }
00040 
00041 
00042 
00043 template<typename LOCK> inline Lock_guard<LOCK>::~Lock_guard()
00044 {
00045   if (_lock)
00046     _lock->clear();
00047 }
00048 
00049 
00050 
00051 template<typename LOCK> inline bool
00052 Lock_guard<LOCK>::was_set(void)
00053 {
00054   return !_lock;
00055 }
00056 
00057 #endif // lock_guard_h

Generated on Mon Sep 26 14:20:11 2005 for Fiasco by  doxygen 1.4.2