roo_threads
API Documentation for roo_threads
Loading...
Searching...
No Matches
roo_threads::doc::counting_semaphore< LeastMaxValue > Class Template Reference

#include <semaphore_api.h>

Public Member Functions

 counting_semaphore (std::ptrdiff_t desired) noexcept
 Constructs semaphore with initial token count.
 
 counting_semaphore (const counting_semaphore &)=delete
 
counting_semaphoreoperator= (const counting_semaphore &)=delete
 
void acquire () noexcept
 Acquires a token, blocking until one is available.
 
bool try_acquire () noexcept
 Attempts to acquire a token without blocking.
 
bool try_acquire_for (const roo_time::Duration &duration) noexcept
 Attempts to acquire a token for a bounded duration.
 
bool try_acquire_until (const roo_time::Uptime &when) noexcept
 Attempts to acquire a token until the given deadline.
 
void release () noexcept
 Releases one token.
 

Detailed Description

template<std::ptrdiff_t LeastMaxValue>
class roo_threads::doc::counting_semaphore< LeastMaxValue >

Definition at line 12 of file semaphore_api.h.

Constructor & Destructor Documentation

◆ counting_semaphore() [1/2]

template<std::ptrdiff_t LeastMaxValue>
roo_threads::doc::counting_semaphore< LeastMaxValue >::counting_semaphore ( std::ptrdiff_t  desired)
explicitnoexcept

Constructs semaphore with initial token count.

Parameters
desiredinitial token count.

◆ counting_semaphore() [2/2]

template<std::ptrdiff_t LeastMaxValue>
roo_threads::doc::counting_semaphore< LeastMaxValue >::counting_semaphore ( const counting_semaphore< LeastMaxValue > &  )
delete

Member Function Documentation

◆ acquire()

template<std::ptrdiff_t LeastMaxValue>
void roo_threads::doc::counting_semaphore< LeastMaxValue >::acquire ( )
noexcept

Acquires a token, blocking until one is available.

◆ operator=()

template<std::ptrdiff_t LeastMaxValue>
counting_semaphore & roo_threads::doc::counting_semaphore< LeastMaxValue >::operator= ( const counting_semaphore< LeastMaxValue > &  )
delete

◆ release()

template<std::ptrdiff_t LeastMaxValue>
void roo_threads::doc::counting_semaphore< LeastMaxValue >::release ( )
noexcept

Releases one token.

◆ try_acquire()

template<std::ptrdiff_t LeastMaxValue>
bool roo_threads::doc::counting_semaphore< LeastMaxValue >::try_acquire ( )
noexcept

Attempts to acquire a token without blocking.

Returns
true if a token was acquired.

◆ try_acquire_for()

template<std::ptrdiff_t LeastMaxValue>
bool roo_threads::doc::counting_semaphore< LeastMaxValue >::try_acquire_for ( const roo_time::Duration &  duration)
noexcept

Attempts to acquire a token for a bounded duration.

Parameters
durationrelative timeout duration.
Returns
true if a token was acquired.

◆ try_acquire_until()

template<std::ptrdiff_t LeastMaxValue>
bool roo_threads::doc::counting_semaphore< LeastMaxValue >::try_acquire_until ( const roo_time::Uptime &  when)
noexcept

Attempts to acquire a token until the given deadline.

Parameters
whenabsolute timeout point.
Returns
true if a token was acquired.

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