Libthreadar 1.6.0
|
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. More... | |
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. More... | |
void | reset () |
reset the object in its prestine state More... | |
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.
libthreadar::ratelier_scatter< T >::ratelier_scatter | ( | unsigned int | size, |
signed int | flag = 0 |
||
) |
Definition at line 125 of file ratelier_scatter.hpp.
void libthreadar::ratelier_scatter< T >::reset |
reset the object in its prestine state
Definition at line 250 of file ratelier_scatter.hpp.
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.
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 |
Definition at line 136 of file ratelier_scatter.hpp.
References THREADAR_BUG.
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.
[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 |
Definition at line 179 of file ratelier_scatter.hpp.
References THREADAR_BUG.