BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslmt::Semaphore Class Reference

#include <bslmt_semaphore.h>

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

Public Member Functions

 Semaphore ()
 
 Semaphore (int count)
 
 ~Semaphore ()
 
void post ()
 
void post (int value)
 
int tryWait ()
 
void wait ()
 
int getValue () const
 

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

Destroy this semaphore.

Member Function Documentation

◆ getValue()

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

Return the value of the current count of this semaphore.

◆ post() [1/2]

void bslmt::Semaphore::post ( )
inline

Atomically increment the count of this semaphore.

◆ post() [2/2]

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

Atomically increase the count of this semaphore by the specified value.

Precondition
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: