semaphore.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @file semaphore.h
  3. * FuriSemaphore
  4. */
  5. #pragma once
  6. #include "base.h"
  7. #include "thread.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef void FuriSemaphore;
  12. /** Allocate semaphore
  13. *
  14. * @param[in] max_count The maximum count
  15. * @param[in] initial_count The initial count
  16. *
  17. * @return pointer to FuriSemaphore instance
  18. */
  19. FuriSemaphore* furi_semaphore_alloc(uint32_t max_count, uint32_t initial_count);
  20. /** Free semaphore
  21. *
  22. * @param instance The pointer to FuriSemaphore instance
  23. */
  24. void furi_semaphore_free(FuriSemaphore* instance);
  25. /** Acquire semaphore
  26. *
  27. * @param instance The pointer to FuriSemaphore instance
  28. * @param[in] timeout The timeout
  29. *
  30. * @return The furi status.
  31. */
  32. FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout);
  33. /** Release semaphore
  34. *
  35. * @param instance The pointer to FuriSemaphore instance
  36. *
  37. * @return The furi status.
  38. */
  39. FuriStatus furi_semaphore_release(FuriSemaphore* instance);
  40. /** Get semaphore count
  41. *
  42. * @param instance The pointer to FuriSemaphore instance
  43. *
  44. * @return Semaphore count
  45. */
  46. uint32_t furi_semaphore_get_count(FuriSemaphore* instance);
  47. #ifdef __cplusplus
  48. }
  49. #endif