Libthreadar 1.5.0
Public Member Functions | List of all members
libthreadar::ratelier_scatter< T > Class Template Reference

the class ratelier_scatter has a fixed length range of slots of arbitrary defined object type 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_scatteroperator= (const ratelier_scatter &ref)=delete
 
ratelier_scatteroperator= (ratelier_scatter &&ref) noexcept=default
 
void scatter (std::unique_ptr< T > &one, signed int flag=0)
 
std::unique_ptr< T > worker_get_one (unsigned int &slot, signed int &flag)
 
void reset ()
 reset the object in its prestine state More...
 

Detailed Description

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

the class ratelier_scatter has a fixed length range of slots of arbitrary defined object type

the number of slot should be greater than the expected number of worker that will fetch data from. This is not mandatory though. Workers fetch an object, use it and "release" it once the job is completed with it. While a single non-worker thread feeds the ratelier_scatter with new objects. Each object taken from the ratelier by a worker is given an index number for the worker can put this object in a given slot of a ratelier_gather object which will be in charge to deliver the in-sequence result of the different jobs to a gathering thread whatever was the execution order of workers.

Definition at line 63 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 120 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

Definition at line 245 of file ratelier_scatter.hpp.

◆ scatter()

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

mean for the non-worker thread to provide data to the ratelier_scatter

Parameters
onean object to scatter to workers
flagis 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 infininte list of object. However the caller may be suspended if the ratelier_scatter is full

Definition at line 131 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 
)

mean for a worker thread to obtain an object in the lowest slot available

Parameters
[out]slotthe slot associated to the object obtained in return of this call
[out]flaga signal associated to this object by from the scattering thread
Returns
the next object available from the ratelier_scaller that has been give by the non-worker thread calling the scatter() method
Note
this call may suspended the caller until the non-worker thread feeds the ratelier_scatter with new data

Definition at line 174 of file ratelier_scatter.hpp.

References THREADAR_BUG.


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