#include <bslmt_barrier.h>
This class defines a thread barrier.
See bslmt_barrier
◆ anonymous enum
◆ Barrier() [1/3]
Create a barrier that requires the specified numArrivals to unblock. 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-level documentation). If clockType is not specified then the realtime system clock is used. The behavior is undefined unless 0 < numArrivals.
◆ Barrier() [2/3]
| bslmt::Barrier::Barrier |
( |
int |
numArrivals, |
|
|
const bsl::chrono::system_clock & |
|
|
) |
| |
|
inline |
Create a barrier that requires the specified numArrivals to unblock. Use the realtime system clock as the clock against which the absTime timeouts passed to the timedWait methods are interpreted (see {Supported Clock-Types} in the component-level documentation). The behavior is undefined unless 0 < numArrivals.
◆ Barrier() [3/3]
| bslmt::Barrier::Barrier |
( |
int |
numArrivals, |
|
|
const bsl::chrono::steady_clock & |
|
|
) |
| |
|
inline |
Create a barrier that requires the specified numArrivals to unblock. Use the monotonic system clock as the clock against which the absTime timeouts passed to the timedWait methods are interpreted (see {Supported Clock-Types} in the component-level documentation). The behavior is undefined unless 0 < numArrivals.
◆ ~Barrier()
| bslmt::Barrier::~Barrier |
( |
| ) |
|
Wait for all signaled threads to unblock and destroy this barrier. (See wait and timedWait below for the meaning of signaled.) Note that the behavior is undefined if a barrier is destroyed while one or more threads are waiting on it.
◆ arrive()
| void bslmt::Barrier::arrive |
( |
| ) |
|
Arrive on this barrier. If this is the last required arrival, signal all the threads that are currently waiting on this barrier to unblock and reset the state of this barrier to its initial state.
◆ clockType()
◆ numArrivals()
| int bslmt::Barrier::numArrivals |
( |
| ) |
const |
|
inline |
Return the required number of arrivals before all waiting threads will unblock.
◆ numThreads()
| int bslmt::Barrier::numThreads |
( |
| ) |
const |
|
inline |
Return the required number of arrivals before all waiting threads will unblock.
- Deprecated:
- Use numArrivals instead.
◆ timedWait() [1/2]
template<class CLOCK , class DURATION >
| int bslmt::Barrier::timedWait |
( |
const bsl::chrono::time_point< CLOCK, DURATION > & |
absTime | ) |
|
|
inline |
Arrive and block until the required number of arrivals have occurred, or until the specified absTime timeout expires. In the former case, signal all the threads that are currently waiting on this barrier to unblock, reset the state of this barrier to its initial state, and return 0. If this method times out before the required number of arrivals, the thread is released to proceed and ceases to contribute to the number of arrivals, and e_TIMED_OUT is returned. Any other return value indicates that an error has occurred. Errors are unrecoverable. After an error, the barrier may be destroyed, but any other use has undefined behavior. absTime is an absolute time represented as an interval from some epoch, which is determined by the clock associated with the time point. Note that timedWait and wait should not generally be used together; if one or more threads called wait while others called timedWait, then if the thread(s) that called timedWait were to time out and not retry, the threads that called wait would never unblock.
◆ timedWait() [2/2]
Arrive and block until the required number of arrivals have occurred, or until the specified absTime timeout expires. In the former case, signal all the threads that are currently waiting on this barrier to unblock, reset the state of this barrier to its initial state, and return 0. If this method times out before the required number of arrivals, the thread is released to proceed and ceases to contribute to the number of arrivals, and e_TIMED_OUT is returned. Any other return value indicates that an error has occurred. Errors are unrecoverable. After an error, the barrier may be destroyed, but any other use has undefined behavior. 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). Note that timedWait and wait should not generally be used together; if one or more threads called wait while others called timedWait, then if the thread(s) that called timedWait were to time out and not retry, the threads that called wait would never unblock.
◆ wait()
| void bslmt::Barrier::wait |
( |
| ) |
|
Arrive and block until the required number of arrivals have occurred. Then signal all the threads that are currently waiting on this barrier to unblock and reset the state of this barrier to its initial state. Note that generally wait and timedWait should not be used together, for reasons explained in the documentation of timedWait.
The documentation for this class was generated from the following file: