StateOS
Loading...
Searching...
No Matches
stateos::Semaphore Struct Reference

create and initialize a semaphore object More...

#include <ossemaphore.h>

Inheritance diagram for stateos::Semaphore:

Public Types

using Ptr = std::unique_ptr<Semaphore>
 result type of Create()

Public Member Functions

constexpr Semaphore ()
 constructor, see the constructor parameters of the class
constexpr Semaphore (const unsigned _init, const unsigned _limit=semDefault)
 constructor, see the constructor parameters of the class
 Semaphore (Semaphore &&_src)
 move constructor
 Semaphore (const Semaphore &)=delete
Semaphore & operator= (Semaphore &&)=delete
Semaphore & operator= (const Semaphore &)=delete
void reset ()
 sem_reset()
void kill ()
 sem_kill()
void destroy ()
 sem_destroy()
int take ()
 sem_take()
int tryWait ()
 sem_tryWait()
int takeISR ()
 sem_takeISR()
template<typename T>
int waitFor (const T &_delay)
 sem_waitFor()
template<typename T>
int waitUntil (const T &_time)
 sem_waitUntil()
int wait ()
 sem_wait()
int give ()
 sem_give()
int post ()
 sem_post()
int giveISR ()
 sem_giveISR()
int release (unsigned _num)
 sem_release()
int releaseISR (unsigned _num)
 sem_releaseISR()
unsigned getValue ()
 sem_getValue()
int takeAsync ()
 sem_takeAsync()
int waitAsync ()
 sem_waitAsync()
int giveAsync ()
 sem_giveAsync()

Static Public Member Functions

static Semaphore Direct ()
 create and initialize static direct semaphore
static Semaphore Binary (const unsigned _init=0)
 create and initialize static binary semaphore
static Semaphore Counting (const unsigned _init=0)
 create and initialize static counting semaphore
static Ptr Create (const unsigned _init, const unsigned _limit=semDefault)
 create dynamic object with manageable resources

Detailed Description

create and initialize a semaphore object

Constructor parameters
  • init: initial value of semaphore counter
  • limit: maximum value of semaphore counter
    • semDirect: direct semaphore
    • semBinary: binary semaphore
    • semCounting: counting semaphore (default)
    • otherwise: limited semaphore

Member Function Documentation

◆ Direct()

Semaphore stateos::Semaphore::Direct ( )
inlinestatic

create and initialize static direct semaphore

Returns
Semaphore object

◆ Binary()

Semaphore stateos::Semaphore::Binary ( const unsigned _init = 0)
inlinestatic

create and initialize static binary semaphore

Parameters
_initinitial value of semaphore counter
Returns
Semaphore object

◆ Counting()

Semaphore stateos::Semaphore::Counting ( const unsigned _init = 0)
inlinestatic

create and initialize static counting semaphore

Parameters
_initinitial value of semaphore counter
Returns
Semaphore object

◆ Create()

Ptr stateos::Semaphore::Create ( const unsigned _init,
const unsigned _limit = semDefault )
inlinestatic

create dynamic object with manageable resources

Parameters
_initinitial value of semaphore counter
_limitmaximum value of semaphore counter (default: semCounting)
Returns
std::unique_pointer / pointer to Semaphore object
Note
use only in thread mode

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