Files
firmware/src/concurrency/Lock.h

36 lines
544 B
C
Raw Normal View History

#pragma once
2020-07-06 10:45:55 +02:00
#include "../freertosinc.h"
2020-09-04 15:03:22 -07:00
namespace concurrency
{
2020-07-06 00:54:30 +02:00
/**
* @brief Simple wrapper around FreeRTOS API for implementing a mutex lock
*/
class Lock
{
public:
Lock();
Lock(const Lock &) = delete;
Lock &operator=(const Lock &) = delete;
/// Locks the lock.
//
// Must not be called from an ISR.
void lock();
// Unlocks the lock.
//
// Must not be called from an ISR.
void unlock();
private:
2020-09-04 15:03:22 -07:00
#ifdef HAS_FREE_RTOS
SemaphoreHandle_t handle;
2020-09-04 15:03:22 -07:00
#endif
};
} // namespace concurrency