summaryrefslogtreecommitdiff
path: root/src/TNetLib/Semaphore.h
blob: a28ee4401866e4e24155ac9c38e2162d20819664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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