Loading...
Searching...
No Matches
libthreadar::ratelier_scatter< T > Class Template Reference

The class ratelier_scatter's purpose it to scatter an ordered set of data to many worker threads. More...

`#include <ratelier_scatter.hpp>`

## Public Member Functions

| ratelier_scatter (unsigned int size, signed int flag=0)
| ratelier_scatter (const ratelier_scatter &ref)=delete
| ratelier_scatter (ratelier_scatter &&ref)=default
ratelier_scatter & | operator= (const ratelier_scatter &ref)=delete
ratelier_scatter & | operator= (ratelier_scatter &&ref) noexcept=default
void | scatter (std::unique_ptr< T > &one, signed int flag=0)
| For the non-worker thread to provide data to the ratelier_scatter.
std::unique_ptr< T > | worker_get_one (unsigned int &slot, signed int &flag)
| For a worker thread to obtain an object in the lowest slot available.
void | reset ()
| reset the object in its prestine state

## Detailed Description

template<class T>
class libthreadar::ratelier_scatter< T >

The class ratelier_scatter's purpose it to scatter an ordered set of data to many worker threads.

Each worker thread fetches a piece of work which is provided with an associated index. The index starts at zero and increases by one for each new piece a worker fetches to keep the sequence order of the provided data.

On the other end a scattering thread feeds the ratelier_scatter with data.

The original design for this class is to work in conjunction with a ratelier_gather structure to gather job result with their associated index, which structure will provide to a gathering thread those results in order, whatever is the effective order the workers completed their task. See ratelier_gather doc for more details.

The number of slot should be greater than the expected number of worker that will fetch data, for they dont stay pending for the scattering thread to refill the structure with new data.

Definition at line 64 of file ratelier_scatter.hpp.

## Constructor & Destructor Documentation

## ratelier_scatter()

template<class T >

libthreadar::ratelier_scatter< T >::ratelier_scatter | ( | unsigned int | size,
|  | signed int | flag = `0`
| ) |  |

Definition at line 125 of file ratelier_scatter.hpp.

## Member Function Documentation

## reset()

template<class T >

void libthreadar::ratelier_scatter< T >::reset | ( |  | ) |

reset the object in its prestine state

Note
  this resets the index to zero.

Definition at line 250 of file ratelier_scatter.hpp.

## scatter()

template<class T >

void libthreadar::ratelier_scatter< T >::scatter | ( | std::unique_ptr< T > & | one,
|  | signed int | flag = `0`
| ) |  |

For the non-worker thread to provide data to the ratelier_scatter.

Parameters

  one | an object to scatter to workers
  flag | is a signal available to worker for any purpose it is associated to the provided object in this call

Note
  the data is added to increasingly higher indexes of the virtually infinite provided list of object, thus the index may overflow, this is not a problem unless you expect having more data in-fly than the maximum integer that an unsigned int may carry. Note also that the caller may be suspended if the ratelier_scatter is full (if no worker did fetch a job).

Definition at line 136 of file ratelier_scatter.hpp.

References THREADAR_BUG.

## worker_get_one()

template<class T >

std::unique_ptr< T > libthreadar::ratelier_scatter< T >::worker_get_one | ( | unsigned int & | slot,
|  | signed int & | flag
| ) |  |

For a worker thread to obtain an object in the lowest slot available.

Parameters

  [out] | slot | the slot associated to the object obtained in return of this call
  [out] | flag | a signal associated to this object by from the scattering thread

Returns
  the next object available from the ratelier_scaller that has been given by the non-worker thread calling the scatter() method

Note
  this call may suspended the caller until the scattering thread feeds the ratelier_scatter with new data

Definition at line 179 of file ratelier_scatter.hpp.

References THREADAR_BUG.

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

- ratelier_scatter.hpp