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

BinarySem.h

Go to the documentation of this file.
00001 #ifndef BINARYSEM_H 00002 #define BINARYSEM_H 00003 00004 #include "common.h" 00005 #include "Exceptions.h" 00006 #include "PtMutex.h" 00007 #include "PtCondition.h" 00008 00009 BOREALIS_NAMESPACE_BEGIN; 00010 00011 class BinarySem 00012 { 00013 public: 00014 BinarySem(bool initiallyPosted = false) 00015 throw (std::exception); 00016 00017 virtual ~BinarySem(); 00018 00019 // Ensures that the sem is posted. One threads presently invoking the 00020 // 'awaitPostThenClear()' method will unblock, and the sem will be cleared. 00021 // Returns 'true' iff the sem was already posted at the time this method 00022 // was called. 00023 bool post() 00024 throw (std::exception); 00025 00026 // If the sem is posted, this clears the sem and returns immediately. 00027 // Otherwise, this waits until the sem is posted, and THEN clears it 00028 // and returns. 00029 void awaitPostThenClear() 00030 throw (std::exception); 00031 00032 // If the sem is posted, this clears the sem and returns immediately. 00033 // Otherwise, this waits until the sem is posted, and returns. This 00034 // does *not* clear the sem. 00035 void awaitPost() 00036 throw (std::exception); 00037 00038 // Simple, non-blocking method to test if the sem is currently posted. 00039 bool isPosted() const 00040 throw (std::exception); 00041 00042 private: 00043 mutable PtMutex _mtx; 00044 mutable PtCondition _cond; 00045 bool _isPosted; 00046 }; 00047 00048 BOREALIS_NAMESPACE_END; 00049 00050 #endif

Generated on Fri Nov 12 15:15:20 2004 for Borealis by doxygen 1.3.8