Mixes for Privacy and Anonymity in the Internet
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
spsc_sema::LightweightSemaphore Class Reference

Public Types

typedef std::make_signed< std::size_t >::type ssize_t
 

Public Member Functions

AE_NO_TSAN LightweightSemaphore (ssize_t initialCount=0)
 
bool tryWait () AE_NO_TSAN
 
void wait () AE_NO_TSAN
 
bool wait (std::int64_t timeout_usecs) AE_NO_TSAN
 
void signal (ssize_t count=1) AE_NO_TSAN
 
ssize_t availableApprox () const AE_NO_TSAN
 

Private Member Functions

bool waitWithPartialSpinning (std::int64_t timeout_usecs=-1) AE_NO_TSAN
 

Private Attributes

weak_atomic< ssize_tm_count
 
Semaphore m_sema
 

Member Typedef Documentation

◆ ssize_t

typedef std::make_signed<std::size_t>::type spsc_sema::LightweightSemaphore::ssize_t

Constructor & Destructor Documentation

◆ LightweightSemaphore()

AE_NO_TSAN spsc_sema::LightweightSemaphore::LightweightSemaphore ( ssize_t  initialCount = 0)

Member Function Documentation

◆ availableApprox()

ssize_t spsc_sema::LightweightSemaphore::availableApprox ( ) const

◆ signal()

void spsc_sema::LightweightSemaphore::signal ( ssize_t  count = 1)

◆ tryWait()

bool spsc_sema::LightweightSemaphore::tryWait ( )

◆ wait() [1/2]

void spsc_sema::LightweightSemaphore::wait ( )

◆ wait() [2/2]

bool spsc_sema::LightweightSemaphore::wait ( std::int64_t  timeout_usecs)

◆ waitWithPartialSpinning()

bool spsc_sema::LightweightSemaphore::waitWithPartialSpinning ( std::int64_t  timeout_usecs = -1)
private

Member Data Documentation

◆ m_count

weak_atomic<ssize_t> spsc_sema::LightweightSemaphore::m_count
private

◆ m_sema

Semaphore spsc_sema::LightweightSemaphore::m_sema
private

Referenced by signal(), and waitWithPartialSpinning().