diff options
Diffstat (limited to 'src/TNetLib/Semaphore.h')
-rw-r--r-- | src/TNetLib/Semaphore.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/TNetLib/Semaphore.h b/src/TNetLib/Semaphore.h new file mode 100644 index 0000000..a28ee44 --- /dev/null +++ b/src/TNetLib/Semaphore.h @@ -0,0 +1,26 @@ +#ifndef _SEMPAHORE_H_ +#define _SEMPAHORE_H_ + +#include <pthread.h> + +namespace TNet { + + class Semaphore { + public: + Semaphore(int initValue = 0); + ~Semaphore(); + + int TryWait(); + void Wait(); + void Post(); + int GetValue(); + + private: + int mSemValue; + pthread_mutex_t mMutex; + pthread_cond_t mCond; + + }; +} //namespace + +#endif |