BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmt::Semaphore Class Reference

#include <bslmt_semaphore.h>

Public Member Functions

 Semaphore ()
 
 Semaphore (int count)
 
 ~Semaphore ()
 Destroy this semaphore.
 
void post ()
 Atomically increment the count of this semaphore.
 
void post (int value)
 
int tryWait ()
 
void wait ()
 
int getValue () const
 Return the value of the current count of this semaphore.
 

Detailed Description

This class implements a portable semaphore type for thread synchronization. It forwards all requests to an appropriate platform-specific implementation.

See bslmt_semaphore

Constructor & Destructor Documentation

◆ Semaphore() [1/2]

bslmt::Semaphore::Semaphore ( )
inline

Create a semaphore initially having a count of 0. This method does not return normally unless there are sufficient system resources to construct the object.

◆ Semaphore() [2/2]

bslmt::Semaphore::Semaphore ( int  count)
inlineexplicit

Create a semaphore initially having the specified count. This method does not return normally unless there are sufficient system resources to construct the object.

◆ ~Semaphore()

bslmt::Semaphore::~Semaphore ( )
inline

Member Function Documentation

◆ getValue()

int bslmt::Semaphore::getValue ( ) const
inline

◆ post() [1/2]

void bslmt::Semaphore::post ( )
inline

◆ post() [2/2]

void bslmt::Semaphore::post ( int  value)
inline

Atomically increase the count of this semaphore by the specified value. The behavior is undefined unless value > 0.

◆ tryWait()

int bslmt::Semaphore::tryWait ( )
inline

If the count of this semaphore is positive, atomically decrement the count and return 0; otherwise, return a non-zero value with no effect on the count.

◆ wait()

void bslmt::Semaphore::wait ( )
inline

Block until the count of this semaphore is a positive value, then atomically decrement the count and return.


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