#include <bslmt_barrier.h>
This class defines a thread barrier.
See bslmt_barrier
◆ anonymous enum
The value timedWait returns when a timeout occurs.
◆ Barrier()
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.
- Precondition
- 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
- 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()
Return the clock type used for timeouts.
◆ 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()
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
- 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
- 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: