Synchronizes an arbitrary number of threads.
More...
#include "nn/nlib/threading/Barrier.h"
Synchronizes an arbitrary number of threads.
- Description
- Set the number of threads (
N
) to be synchronized in the Init
function. Calling the Wait
function stops that thread when the number of threads reached is less than N
. All threads are awakened and execution is resumed when the number of ready threads reach N
. When this occurs, the counter is reset and the thread halts when it reaches the Wait
function.
1 CondVar
is used internally. Barrier barrier;
if (0 != barrier.Init(Number of waiting theads)) { ERROR; }
....
barrier.Wait();
....
barrier.Wait();
....
Definition at line 20 of file Barrier.h.
§ Init()
nn::nlib::threading::Barrier::Init |
( |
unsigned int |
count | ) |
|
|
inlinenoexcept |
Initializes a barrier.
- Parameters
-
[in] | count | Number of threads to wait for. |
- Return values
-
0 | No error occurred. |
EINVAL | Indicates that count is 0 . |
ENOMEM | Indicates that there are not enough system resources. |
Definition at line 30 of file Barrier.h.
§ Wait()
nn::nlib::threading::Barrier::Wait |
( |
| ) |
|
|
inlinenoexcept |
Waits for a thread.
- Return values
-
0 | No error occurred. |
EBADF | Indicates that the Init function has not been called. |
ENOMEM | Indicates that there are not enough system resources. |
Definition at line 38 of file Barrier.h.
The documentation for this class was generated from the following files: