rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
ripple::basic_semaphore< Mutex, CondVar > Class Template Reference

#include <semaphore.h>

Collaboration diagram for ripple::basic_semaphore< Mutex, CondVar >:
Collaboration graph
[legend]

Public Types

using size_type = std::size_t
 

Public Member Functions

 basic_semaphore (size_type count=0)
 Create the semaphore, with an optional initial count.
 
void notify ()
 Increment the count and unblock one waiting thread.
 
void wait ()
 Block until notify is called.
 
bool try_wait ()
 Perform a non-blocking wait.
 

Private Attributes

Mutex m_mutex
 
CondVar m_cond
 
std::size_t m_count
 

Detailed Description

template<class Mutex, class CondVar>
class ripple::basic_semaphore< Mutex, CondVar >

Definition at line 57 of file semaphore.h.

Member Typedef Documentation

◆ size_type

template<class Mutex , class CondVar >
using ripple::basic_semaphore< Mutex, CondVar >::size_type = std::size_t

Definition at line 65 of file semaphore.h.

Constructor & Destructor Documentation

◆ basic_semaphore()

template<class Mutex , class CondVar >
ripple::basic_semaphore< Mutex, CondVar >::basic_semaphore ( size_type  count = 0)
explicit

Create the semaphore, with an optional initial count.

If unspecified, the initial count is zero.

Definition at line 70 of file semaphore.h.

Member Function Documentation

◆ notify()

template<class Mutex , class CondVar >
void ripple::basic_semaphore< Mutex, CondVar >::notify ( )

Increment the count and unblock one waiting thread.

Definition at line 76 of file semaphore.h.

◆ wait()

template<class Mutex , class CondVar >
void ripple::basic_semaphore< Mutex, CondVar >::wait ( )

Block until notify is called.

Definition at line 85 of file semaphore.h.

◆ try_wait()

template<class Mutex , class CondVar >
bool ripple::basic_semaphore< Mutex, CondVar >::try_wait ( )

Perform a non-blocking wait.

Returns
true If the wait would be satisfied.

Definition at line 97 of file semaphore.h.

Member Data Documentation

◆ m_mutex

template<class Mutex , class CondVar >
Mutex ripple::basic_semaphore< Mutex, CondVar >::m_mutex
private

Definition at line 60 of file semaphore.h.

◆ m_cond

template<class Mutex , class CondVar >
CondVar ripple::basic_semaphore< Mutex, CondVar >::m_cond
private

Definition at line 61 of file semaphore.h.

◆ m_count

template<class Mutex , class CondVar >
std::size_t ripple::basic_semaphore< Mutex, CondVar >::m_count
private

Definition at line 62 of file semaphore.h.