WrappedSemaphore.h 565 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef WRAPPEDSEMAPHORE_H
  2. #define WRAPPEDSEMAPHORE_H
  3. #ifdef ESP_PLATFORM
  4. #include "freertos/FreeRTOS.h"
  5. #include "freertos/semphr.h"
  6. #elif __APPLE__
  7. #include <dispatch/dispatch.h>
  8. #else
  9. #include <semaphore.h>
  10. #endif
  11. class WrappedSemaphore
  12. {
  13. private:
  14. #ifdef ESP_PLATFORM
  15. xSemaphoreHandle semaphoreHandle;
  16. #elif __APPLE__
  17. dispatch_semaphore_t semaphoreHandle;
  18. #else
  19. sem_t semaphoreHandle;
  20. #endif
  21. public:
  22. WrappedSemaphore(int maxVal = 200);
  23. ~WrappedSemaphore();
  24. int wait();
  25. int twait(long milliseconds = 10);
  26. void give();
  27. };
  28. #endif