Sem.hpp
1 //
2 // Created by xiong on 2022/6/9.
3 //
4 
5 #ifndef EMX_Sem_HPP
6 #define EMX_Sem_HPP
7 
8 #include "core/EmxTypeDef.hpp"
9 #include <semaphore.h>
10 
11 namespace Emx {
17  class Sem {
18  public:
19  Sem() {
20  m_semId = nullptr;
21  }
22 
23  ~Sem() {
24  Destroy();
25  }
26 
33  ErrCodeE Create(const char *path, int32_t initValue);
34 
35 // ErrCodeE Create(int32_t initValue, int32_t shared);
36 
42  ErrCodeE Wait(int32_t timeoutMs = -1);
43 
46 
48  int32_t Get();
49 
51  void Destroy();
52 
53  private:
54  sem_t *m_semId;
55  char m_name[EMX_MAX_PATH_SIZE];
56 
57  };
58 
60 }
61 
62 #endif //EMX_Sem_HPP
进程间同步信号量
Definition: Sem.hpp:17
ErrCodeE Wait(int32_t timeoutMs=-1)
等待信号量
int32_t Get()
获取信号量的值
Sem()
Definition: Sem.hpp:19
~Sem()
Definition: Sem.hpp:23
void Destroy()
销毁信号量
ErrCodeE Create(const char *path, int32_t initValue)
创建信号量
ErrCodeE Post()
释放信号量
ErrCodeE
错误码定义
Definition: EmxTypeDef.hpp:29
Definition: EmxGpio.hpp:10