00001 #ifndef FIFOCRITICALSECTION_H 00002 #define FIFOCRITICALSECTION_H 00003 00004 #include <ILockable.h> 00005 #include <PtMutex.h> 00006 #include <PtCondition.h> 00007 #include <exception> 00008 #include <list> 00009 00010 BOREALIS_NAMESPACE_BEGIN; 00011 00012 /* 00013 Guarantees first-come, first-serve access to a critical section. 00014 */ 00015 class FifoCriticalSection : public ILockable 00016 { 00017 public: 00018 FifoCriticalSection() 00019 throw (exception); 00020 00021 // Behavior is undefined If you delete this object while at least one thread 00022 // is awaiting or holding the lock. 00023 virtual ~FifoCriticalSection(); 00024 00025 // If an exception is thrown, the state of this object can no longer be 00026 // trusted. 00027 virtual void lock() 00028 throw (exception); 00029 00030 // If an exception is thrown, the state of this object can no longer be 00031 // trusted. 00032 virtual void unlock() 00033 throw (exception); 00034 00035 private: 00036 PtMutex _mtx; 00037 list<PtCondition *> _waiters; 00038 bool _held; 00039 }; 00040 00041 BOREALIS_NAMESPACE_END; 00042 00043 #endif