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

helping_lock.h

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #ifndef helping_lock_h
00004 #define helping_lock_h
00005 
00006 #include "lock_guard.h"
00007 #include "switch_lock.h"
00008 
00009 //
00010 // INTERFACE definition follows 
00011 //
00012 
00013 
00019 class Helping_lock  
00020 {
00021   Switch_lock _switch_lock;
00022 
00023 public:
00024   static bool threading_system_active;
00025 
00026 public:  
00028   inline Helping_lock();
00029   
00033   bool test_and_set();
00034   
00039   inline void lock();
00040   
00044   inline bool test();
00045   
00050   inline void clear();
00051   
00055   inline Context* lock_owner();
00056 };
00057 
00058 typedef Lock_guard<Helping_lock> Helping_lock_guard;
00059 
00060 //
00061 // IMPLEMENTATION includes follow (for use by inline functions)
00062 //
00063 
00064 
00065 #include "globals.h"
00066 #include "panic.h"
00067 #include "std_macros.h"
00068 
00069 //
00070 // IMPLEMENTATION of inline functions (and needed classes)
00071 //
00072 
00073 
00074 
00077 inline Helping_lock::Helping_lock()
00078 {
00079   _switch_lock.initialize();
00080 }
00081 
00082 
00088 inline void 
00089 Helping_lock::lock()
00090 {
00091   check ( test_and_set() == false );
00092 }
00093 
00094 
00099 inline bool
00100 Helping_lock::test()
00101 {
00102   if (EXPECT_FALSE( ! threading_system_active) ) // still initializing?
00103     return false;
00104 
00105   return _switch_lock.test();
00106 }
00107 
00108 
00114 inline void
00115 Helping_lock::clear()
00116 {
00117   if (EXPECT_FALSE( ! threading_system_active) ) // still initializing?
00118     return;
00119 
00120   _switch_lock.clear();
00121 }
00122 
00123 
00128 inline Context*
00129 Helping_lock::lock_owner()
00130 {
00131   if (EXPECT_FALSE( ! threading_system_active) ) // still initializing?
00132     return current();
00133 
00134   return _switch_lock.lock_owner();
00135 }
00136 
00137 #endif // helping_lock_h

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