pm_semaphore.h 643 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * File : pm_semaphore.h
  3. * COPYRIGHT (C) 2012-2017, Shanghai Real-Thread Technology Co., Ltd
  4. *
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2017-11-05 realthread the first version
  8. */
  9. #pragma once
  10. #include <rtthread.h>
  11. namespace Persimmon
  12. {
  13. class Semaphore
  14. {
  15. public:
  16. enum type
  17. {
  18. FIFO = RT_IPC_FLAG_FIFO, /**< FIFOed IPC. @ref IPC. */
  19. PRIO = RT_IPC_FLAG_PRIO, /**< PRIOed IPC. @ref IPC. */
  20. };
  21. Semaphore(const char *name, rt_uint32_t value, rt_uint8_t flag = FIFO);
  22. virtual ~Semaphore();
  23. int take(int tick);
  24. void release(void);
  25. private:
  26. rt_sem_t semaphore;
  27. };
  28. }