rippled
Public Types | Public Member Functions | Private Attributes | List of all members
ripple::basic_semaphore< Mutex, CondVar > Class Template Reference
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. More...
 
void notify ()
 Increment the count and unblock one waiting thread. More...
 
void wait ()
 Block until notify is called. More...
 
bool try_wait ()
 Perform a non-blocking wait. More...
 

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 29 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 37 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 42 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 48 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 57 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 69 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 32 of file semaphore.h.

◆ m_cond

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

Definition at line 33 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 34 of file semaphore.h.