Program Listing for File Sema.h¶
↰ Return to documentation for file (components/Util/src/Sema.h
)
#ifndef UTIL_SEMA_H
#define UTIL_SEMA_H
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <cstdint>
namespace util {
class Semaphore
{
public:
Semaphore(const char* dbg_name);
Semaphore(Semaphore&& other);
~Semaphore();
Semaphore(Semaphore const&) = delete;
Semaphore& operator=(Semaphore const&) = delete;
Semaphore& operator=(Semaphore&&) = delete;
void take();
bool take(std::uint32_t timeout_ms);
void give();
void wait();
private:
Semaphore() {}
SemaphoreHandle_t m_handle;
const char* m_dbg_name;
};
} // namespace util
#endif // UTIL_SEMA_H