FreeRTOScpp
Loading...
Searching...
No Matches
BinarySemaphore Class Reference

Binary Semaphore Wrapper. More...

#include <SemaphoreCPP.h>

Inheritance diagram for BinarySemaphore:
Collaboration diagram for BinarySemaphore:

Public Member Functions

 BinarySemaphore (char const *name=nullptr)
 Constructor.
 
 ~BinarySemaphore ()
 Destructor.
 
bool give () override
 Give the Semaphore.
 
bool give_ISR (portBASE_TYPE &waswoken)
 Give the Semaphore inside an ISR.
 
bool take (TickType_t delay=portMAX_DELAY) override
 Take the semaphore.
 
bool take_ISR (portBASE_TYPE &waswoken)
 

Private Member Functions

 BinarySemaphore (BinarySemaphore const &)=delete
 We are not copyable.
 
void operator= (BinarySemaphore const &)=delete
 We are not assignable.
 

Private Attributes

SemaphoreHandle_t sema
 

Detailed Description

Binary Semaphore Wrapper.

Example Usage:

Semaphore sema("MySema");
// In some task
sema.give();
// In some other task
sema.take();
// In some ISR
portBASE_TYPE woken = 0;
...
sema.give_ISR(woken);
...
portYIELD_FROM_ISR(woken);
return;
Binary Semaphore Wrapper.
Definition SemaphoreCPP.h:77
SemaphoreHandle_t sema
Definition SemaphoreCPP.h:141

Constructor & Destructor Documentation

◆ BinarySemaphore() [1/2]

BinarySemaphore::BinarySemaphore ( char const * name = nullptr)
inline

Constructor.

Parameters
nameName to give semaphore, used for Debug Registry if setup

◆ ~BinarySemaphore()

BinarySemaphore::~BinarySemaphore ( )
inline

Destructor.

Delete the semaphore.

◆ BinarySemaphore() [2/2]

BinarySemaphore::BinarySemaphore ( BinarySemaphore const & )
privatedelete

We are not copyable.

Member Function Documentation

◆ give()

bool BinarySemaphore::give ( )
inlineoverridevirtual

Give the Semaphore.

Implements Lockable.

◆ give_ISR()

bool BinarySemaphore::give_ISR ( portBASE_TYPE & waswoken)
inline

Give the Semaphore inside an ISR.

Parameters
waswokenThe flag variable used to indicate if we need to run the scheduler when we exit the ISR.

◆ operator=()

void BinarySemaphore::operator= ( BinarySemaphore const & )
privatedelete

We are not assignable.

◆ take()

bool BinarySemaphore::take ( TickType_t delay = portMAX_DELAY)
inlineoverridevirtual

Take the semaphore.

Parameters
delayThe number of ticks to wait for the semaphore

Implements Lockable.

◆ take_ISR()

bool BinarySemaphore::take_ISR ( portBASE_TYPE & waswoken)
inline

Member Data Documentation

◆ sema

SemaphoreHandle_t BinarySemaphore::sema
private

The documentation for this class was generated from the following file: