sptk2 logo
SPTK Home Page
Public Member Functions | List of all members
sptk::Semaphore Class Reference

Generic unnamed semaphore class. More...

#include <Semaphore.h>

Public Member Functions

void post ()
 Post the semaphore. More...
 
bool sleep_for (std::chrono::milliseconds timeout)
 Wait until semaphore value is greater than zero, or until timeout interval is passed. More...
 
bool sleep_until (DateTime timeout)
 Wait until semaphore value is greater than zero, or until timeoutAt occurs. More...
 

Detailed Description

Generic unnamed semaphore class.

Member Function Documentation

◆ post()

void sptk::Semaphore::post ( )

◆ sleep_for()

bool sptk::Semaphore::sleep_for ( std::chrono::milliseconds  timeout)

Wait until semaphore value is greater than zero, or until timeout interval is passed.

If semaphore value is greater than zero, decreases semaphore value by one and returns true.

Parameters
timeoutWait timeout
Returns
true if semaphore was posted (signaled), or false if timeout occurs

Referenced by sptk::SynchronizedQueue< T >::pop(), sptk::SynchronizedList< T >::pop_back(), and sptk::SynchronizedList< T >::pop_front().

◆ sleep_until()

bool sptk::Semaphore::sleep_until ( DateTime  timeout)

Wait until semaphore value is greater than zero, or until timeoutAt occurs.

If semaphore value is greater than zero, decreases semaphore value by one and returns true.

Parameters
timeoutTimeout moment
Returns
true if semaphore was posted (signaled), or false if timeout occurs

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

Fri Oct 14 2022 09:58:44: SPTK 5.4.1