00001 00002 #ifndef SIMPLE_SEMAPHORE_H 00003 #define SIMPLE_SEMAPHORE_H 00004 00005 class SimpleSemaphore 00006 { 00007 protected: 00008 int _key; 00009 int _valid; 00010 00011 public: 00012 SimpleSemaphore( int key ) : _key(key), _valid(0) {} 00013 00014 virtual int valid() const { return _valid; } 00015 00016 // after constructing, these are the two methods that can change 00017 // the _valid flag to true. 00018 virtual int create() = 0; 00019 virtual int attach() = 0; 00020 virtual int remove() = 0; 00021 00022 // once initialized, use these methods to lock & unlock the semaphore 00023 virtual int lock() = 0; 00024 virtual int unlock() = 0; 00025 00026 virtual void print( int pause_flag = 1) {} 00027 }; 00028 00029 #endif 00030