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

#include <bslmt_sluice.h>

Detailed Description

This class controls the release of threads from a common synchronization point. One or more threads may "enter" a Sluice object, and then wait to be released. Either one waiting thread (via the signalOne method), or all waiting threads (via the signalAll method), may be signaled for release. In any case, Sluice provides a guarantee against starvation.

See bslmt_sluice

Public Types

enum  { e_TIMED_OUT = TimedSemaphore::e_TIMED_OUT }
 

Public Member Functions

 Sluice (bslma::Allocator *basicAllocator=0)
 
 Sluice (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 ~Sluice ()
 
const void * enter ()
 
void signalAll ()
 
void signalOne ()
 
int timedWait (const void *token, const bsls::TimeInterval &absTime)
 
void wait (const void *token)
 
bsls::SystemClockType::Enum clockType () const
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The value timedWait returns when a timeout occurs.

Enumerator
e_TIMED_OUT 

Constructor & Destructor Documentation

◆ Sluice() [1/2]

bslmt::Sluice::Sluice ( bslma::Allocator basicAllocator = 0)
explicit

Create a sluice. Optionally specify a clockType indicating the type of the system clock against which the bsls::TimeInterval absTime timeouts passed to the timedWait method are to be interpreted (see {Supported Clock-Types} in the component documentation). If clockType is not specified then the realtime system clock is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ Sluice() [2/2]

bslmt::Sluice::Sluice ( bsls::SystemClockType::Enum  clockType,
bslma::Allocator basicAllocator = 0 
)
explicit

◆ ~Sluice()

bslmt::Sluice::~Sluice ( )

Destroy this sluice.

Member Function Documentation

◆ clockType()

bsls::SystemClockType::Enum bslmt::Sluice::clockType ( ) const
inline

Return the clock type used for timeouts.

◆ enter()

const void * bslmt::Sluice::enter ( )

Enter this sluice, and return the token on which the calling thread must subsequently wait.

Precondition
The behavior is undefined unless wait or timedWait is invoked with the token before this sluice is destroyed.

◆ signalAll()

void bslmt::Sluice::signalAll ( )

Signal all threads that have entered this sluice and have not yet been released.

◆ signalOne()

void bslmt::Sluice::signalOne ( )

Signal one thread that has entered this sluice and has not yet been released.

◆ timedWait()

int bslmt::Sluice::timedWait ( const void *  token,
const bsls::TimeInterval absTime 
)

Wait for the specified token to be signaled, or until the specified absTime timeout expires. absTime is an absolute time represented as an interval from some epoch, which is determined by the clock indicated at construction (see {Supported Clock-Types} in the component-level documentation). Return 0 on success, and e_TIMED_OUT on timeout. Any other value indicates that an error has occurred. Errors are unrecoverable. After an error, the sluice may be destroyed, but any other use has undefined behavior. The token is released whether or not a timeout occurred.

Precondition
The behavior is undefined unless token was obtained from a call to enter by this thread, and was not subsequently released (via a call to timedWait or wait).

◆ wait()

void bslmt::Sluice::wait ( const void *  token)

Wait for the specified token to be signaled, and release the token.

Precondition
The behavior is undefined unless token was obtained from a call to enter by this thread, and was not subsequently released (via a call to timedWait or wait).

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