libthreadar::barrier Class Reference

the class barrier allows several threads to synchronize between them More...

`#include <barrier.hpp>`

## Public Member Functions

| barrier (unsigned int num)
| The constructor. More...
| barrier (const barrier &ref)=delete
| no copy constructor
| barrier (barrier &&ref) noexcept=default
| no move constructor
barrier & | operator= (const barrier &ref)=delete
| no assignment operator
barrier & | operator= (barrier &&ref) noexcept=default
| no move operator
| ~barrier () noexcept(false)
| The destructor. More...
void | wait ()
| suspend the calling thread waiting for other up to 'num' other thread to call wait too More...
unsigned int | get_count () const
| return the barrier size More...
unsigned int | get_waiting_count () const
| return the number of thread waiting on the barrier or just released from it More...

## Static Public Member Functions

static std::string | used_implementation ()

## Detailed Description

the class barrier allows several threads to synchronize between them

the number of thread to synchronize is given in the constructor argument 'num'. All thread calling the wait() method get locked until 'num' thread(s) have called this wait() method at which time they are all unlocked. The barrier object is then ready for a new cycle.

Note
  The barrier shall not be destroyed if at least one thread is waiting (locked) on it

Definition at line 56 of file barrier.hpp.

## Constructor & Destructor Documentation

## barrier()

libthreadar::barrier::barrier | ( | unsigned int | num | ) |

The constructor.

Parameters

  [in] | num | is the number of thread to synchronize

## ~barrier()

libthreadar::barrier::~barrier | ( |  | ) |

noexcept

The destructor.

Note
  A barrier object must not be destroyed if some thread are suspended calling wait() on it

## Member Function Documentation

## get_count()

unsigned int libthreadar::barrier::get_count | ( |  | ) | const

inline

return the barrier size

Definition at line 88 of file barrier.hpp.

## get_waiting_count()

unsigned int libthreadar::barrier::get_waiting_count | ( |  | ) | const

inline

return the number of thread waiting on the barrier or just released from it

Note
  this is to be seen as an approximation as a thread can be about to be suspended but not yet counted, as well as a thread may be just released while not yet removed from the count

Definition at line 95 of file barrier.hpp.

## used_implementation()

static std::string libthreadar::barrier::used_implementation | ( |  | ) |

inline static

Definition at line 97 of file barrier.hpp.

## wait()

void libthreadar::barrier::wait | ( |  | ) |

suspend the calling thread waiting for other up to 'num' other thread to call wait too

Note
  A thread is suspended up to the time a total amount of 'num' threads (as given to the barrier constructor) have also called wait(). Then all suspended thread are resumed.

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

- barrier.hpp