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

the class ratelier_gather's purpose it gather works from several worker threads More...

`#include <ratelier_gather.hpp>`

## Public Member Functions

| ratelier_gather (unsigned int size, signed int flag=0)
| ratelier_gather (const ratelier_gather &ref)=delete
| ratelier_gather (ratelier_gather &&ref)=default
ratelier_gather & | operator= (const ratelier_gather &ref)=delete
ratelier_gather & | operator= (ratelier_gather &&ref) noexcept=default
void | worker_push_one (unsigned int slot, std::unique_ptr< T > &one, signed int flag=0)
| provides to a worker thread a mean to given data with its associated index to the gathering thread
void | gather (std::deque< std::unique_ptr< T > > &ones, std::deque< signed int > &flag)
| obtain the lowest continuous filled slots from the ratelier_gather and free them
void | reset ()
| reset the object in its prestine state

## Detailed Description

template<class T>
class libthreadar::ratelier_gather< T >

the class ratelier_gather's purpose it gather works from several worker threads

Each worker has to send its job result to the ratelier_gather with an index number. This index is used to provide the jobs in sequence to the gathering thread and starts to zero. If a index is missing no data is delivered to the gathering thread until a worker thread provides it. The gathering thread is thus garantied that whatever the execution order of workers their resulting job is provided in sequence to the gathering thread.

The original design for this class is to work in conjunction with a ratelier_scatter when a sequence of data has to be processed by many workers, but the resulting of the processed data should also be ordered following the original data order whatever the speed or task complexity each worker performed or addressed compared to the others.

       +--------------------+
       | scattering thread  |
       +--------------------+
                  |
                  |
                  V
         (ratelier_scatter)
         /        |       \
        /         |        \
    +-------+  +-------+  +-------+
    |worker1|  |worker2|  |worker3|
    +-------+  +-------+  +-------+
        \         |        /
         \        |       /
          V       V      V
         (ratelier_gather)
                  |
                  |
                  V
       +--------------------+
       | gathering  thread  |
       +--------------------+

Note
  "ratelier" is a french word that translates here to "rack" in the meaning of the structure where soldiers put their weapons, or if you prefer piece of metal that can hold and park a set of bicycles.

The number of slots should be greater than the number of workers that fill the ratelier with data to avoid having working pending for a slot. Workers put objects each at a given slot and a non-worker thread (the gathering thread) fetches those objects, which are provided in order, this releases the corresponding slots of the ratelier_gather object for workers to drop next results in it.

Definition at line 99 of file ratelier_gather.hpp.

## Constructor & Destructor Documentation

## ratelier_gather()

template<class T >

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

Definition at line 156 of file ratelier_gather.hpp.

## Member Function Documentation

## gather()

template<class T >

void libthreadar::ratelier_gather< T >::gather | ( | std::deque< std::unique_ptr< T > > & | ones,
|  | std::deque< signed int > & | flag
| ) |  |

obtain the lowest continuous filled slots from the ratelier_gather and free them

Parameters

  [out] | ones | is a list of continuously indexed objects which immediately follows the list provided by a previous call to gather().
  [out] | flag | is the purpose free signal transmitted by the workers and associated to each object

Note
  the provided arguments, ones and flags, should always have the same size.

Definition at line 216 of file ratelier_gather.hpp.

References THREADAR_BUG.

## reset()

template<class T >

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

reset the object in its prestine state

this restarts the index to zero. The next index that a worker should give for any data be provided to the gathering thread should be zero.

Definition at line 287 of file ratelier_gather.hpp.

## worker_push_one()

template<class T >

void libthreadar::ratelier_gather< T >::worker_push_one | ( | unsigned int | slot,
|  | std::unique_ptr< T > & | one,
|  | signed int | flag = `0`
| ) |  |

provides to a worker thread a mean to given data with its associated index to the gathering thread

Parameters

  [in] | slot | is the slot number associated to the provided object "one"
  [in] | one | is the object to push to the gathering thread
  [in] | flag | is a purpose free signal to send to the gathering thread as associated to this object.

Note
  if this slot number has already been provided an exception is thrown,
  if the ratelier_gather is full, the caller will be suspended until the non-worker gathering thread calls gather() to make some room.

Definition at line 166 of file ratelier_gather.hpp.

References THREADAR_BUG.

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

- ratelier_gather.hpp