mavtables  0.2.1
MAVLink router and firewall.
Public Member Functions | List of all members
semaphore Class Reference

#include <semaphore.hpp>

Collaboration diagram for semaphore:
Collaboration graph

Public Member Functions

 semaphore (const semaphore &other)=delete
 
 semaphore (semaphore &&other)=delete
 
 semaphore (size_t initial_value=0)
 
void notify ()
 
void wait ()
 
template<class Rep , class Period >
bool wait_for (const std::chrono::duration< Rep, Period > &rel_time)
 
template<class Clock , class Duration >
bool wait_until (const std::chrono::time_point< Clock, Duration > &timeout_time)
 
semaphoreoperator= (const semaphore &other)=delete
 
semaphoreoperator= (semaphore &&other)=delete
 

Detailed Description

A weak semaphore implementation.

Note
This uses a different naming scheme than the rest of this project because it is intended to have the same feel as the standard library.
This semaphore implementation is based on https://gist.github.com/sguzman/9594227

Definition at line 36 of file semaphore.hpp.

Constructor & Destructor Documentation

◆ semaphore() [1/3]

semaphore::semaphore ( const semaphore other)
delete

◆ semaphore() [2/3]

semaphore::semaphore ( semaphore &&  other)
delete

◆ semaphore() [3/3]

semaphore::semaphore ( size_t  initial_value = 0)

Construct a semaphore with the given initial value.

Parameters
initial_valueThe initial value of the semaphore. Defaults to 0.

Definition at line 28 of file semaphore.cpp.

Member Function Documentation

◆ notify()

void semaphore::notify ( )

Signal the semaphore.

Increments the semaphore.

Definition at line 38 of file semaphore.cpp.

◆ operator=() [1/2]

semaphore& semaphore::operator= ( const semaphore other)
delete

◆ operator=() [2/2]

semaphore& semaphore::operator= ( semaphore &&  other)
delete

◆ wait()

void semaphore::wait ( )

Wait on the semaphore.

Decrements the semaphore.

Definition at line 52 of file semaphore.cpp.

◆ wait_for()

template<class Rep , class Period >
bool semaphore::wait_for ( const std::chrono::duration< Rep, Period > &  rel_time)

Wait on the semaphore, or a given duration timeout.

Parameters
rel_timeThe duration of the timeout.
Return values
trueThe semaphore has been successfully decremented.
falseThe semaphore timed out.

Definition at line 66 of file semaphore.hpp.

◆ wait_until()

template<class Clock , class Duration >
bool semaphore::wait_until ( const std::chrono::time_point< Clock, Duration > &  timeout_time)

Wait on the semaphore, or a given timepoint timeout.

Parameters
timeout_timeThe timepoint for the timeout.
Return values
trueThe semaphore has been successfully decremented.
falseThe semaphore timed out.

Definition at line 90 of file semaphore.hpp.


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