Allolib  1.0
C++ Components For Interactive Multimedia
al::Threads< ThreadFunction > Class Template Reference

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/system/al_Thread.hpp>

Classes

struct  Worker
 A thread and function. More...
 

Public Member Functions

 Threads (int size=0)
 
int size () const
 Returns number of workers.
 
void resize (int n)
 Resize number of workers.
 
void start (bool joinAll=true)
 Start all worker threads.
 
void join ()
 Join all worker threads.
 
Workerworker (int i)
 Get a worker.
 
Threadthread (int i)
 Get a worker thread.
 
ThreadFunctionfunction (int i)
 Get a worker thread function.
 
template<class T >
double range (T max, T min=T(0))
 Get worker sub-interval range of a full interval [min, max) More...
 
template<class T >
void getInterval (T *interval, int i, T max, T min=T(0))
 Get worker sub-interval of a full interval [min, max) More...
 

Protected Member Functions

void clear ()
 

Protected Attributes

int mSize
 
WorkermWorkers
 

Detailed Description

template<class ThreadFunction>
class al::Threads< ThreadFunction >

Multiple threads acting as a single work unit

Definition at line 142 of file al_Thread.hpp.

Constructor & Destructor Documentation

◆ Threads()

template<class ThreadFunction >
al::Threads< ThreadFunction >::Threads ( int  size = 0)
inline
Parameters
[in]sizenumber of worker threads

Definition at line 151 of file al_Thread.hpp.

Member Function Documentation

◆ getInterval()

template<class ThreadFunction >
template<class T >
void al::Threads< ThreadFunction >::getInterval ( T *  interval,
int  i,
max,
min = T(0) 
)
inline

Get worker sub-interval of a full interval [min, max)

Parameters
[out]intervaltwo-element array containing endpoints of sub-interval
[in]iworker index
[in]maxfull interval max endpoint
[in]minfull interval min endpoint

Definition at line 207 of file al_Thread.hpp.

◆ range()

template<class ThreadFunction >
template<class T >
double al::Threads< ThreadFunction >::range ( max,
min = T(0) 
)
inline

Get worker sub-interval range of a full interval [min, max)

This is useful for determining how to break up for loops into sub-intervals. E.g., if the full loop interval is [ 0, N ), then the ith worker's interval is [ range(N)*i, range(N)*(i+1) ).

Definition at line 196 of file al_Thread.hpp.


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