Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

bslmt::Semaphore Class Reference

#include <bslmt_semaphore.h>

List of all members.

Public Member Functions

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

Detailed Description

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

See Component bslmt_semaphore


Constructor & Destructor Documentation

bslmt::Semaphore::Semaphore (  ) 

Create a semaphore initially having a count of 0.

bslmt::Semaphore::Semaphore ( int  count  )  [explicit]

Create a semaphore initially having the specified count.

bslmt::Semaphore::~Semaphore (  ) 

Destroy this semaphore.


Member Function Documentation

void bslmt::Semaphore::post (  ) 

Atomically increment the count of this semaphore.

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

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

int bslmt::Semaphore::tryWait (  ) 

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.

void bslmt::Semaphore::wait (  ) 

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

int bslmt::Semaphore::getValue (  )  const

Return the value of the current count of this semaphore.


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