#include <thread.h>
Public Member Functions | |
barrier (unsigned count) | |
Construct a barrier with an initial size. | |
~barrier () | |
Destroy barrier and release pending threads. | |
void | set (unsigned count) |
Dynamically alter the number of threads required. | |
void | wait (void) |
Wait at the barrier until the count of threads waiting is reached. | |
bool | wait (timeout_t timeout) |
Wait at the barrier until either the count of threads waiting is reached or a timeout has occurred. | |
Static Public Member Functions | |
static void | wait (barrier &sync) |
Convenience function to wait at a barrier. | |
static bool | wait (barrier &sync, timeout_t timeout) |
Convenience function to wait at a barrier with a timeout. | |
static void | set (barrier &sync, unsigned count) |
Convenience function to set a barrier count. |
A barrier waits until a specified number of threads have all reached the barrier, and then releases all the threads together. This implimentation works regardless of whether the thread library supports barriers since it is built from conditional. It also differs in that the number of threads required can be changed dynamically at runtime, unlike pthread barriers which, when supported, have a fixed limit defined at creation time. Since we use conditionals, another feature we can add is optional support for a wait with timeout.
Definition at line 903 of file thread.h.
ucc::barrier::barrier | ( | unsigned | count | ) |
static void ucc::barrier::set | ( | barrier & | sync, | |
unsigned | count | |||
) | [inline, static] |
void ucc::barrier::set | ( | unsigned | count | ) |
Dynamically alter the number of threads required.
If the size is set below the currently waiting threads, then the barrier releases.
count | of threads required. |
static void ucc::barrier::wait | ( | barrier & | sync | ) | [inline, static] |
bool ucc::barrier::wait | ( | timeout_t | timeout | ) |
Wait at the barrier until either the count of threads waiting is reached or a timeout has occurred.
timeout | to wait in milliseconds. |
Reimplemented from ucc::Conditional.