Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
gts::ParallelFor Class Reference

A construct that maps parallel-for behavior to a MicroScheduler. More...

#include <ParallelFor.h>

Public Member Functions

GTS_INLINE ParallelFor (MicroScheduler &scheduler, uint32_t priority=0)
 
template<typename TPartitioner , typename TRange , typename TFunc >
GTS_INLINE void operator() (TRange const &range, TFunc func, TPartitioner partitioner, void *pUserData, bool block=true)
 Applies the given function 'func' to the specified iteration 'range'. More...
 
template<typename TIter , typename TFunc , typename TPartitioner = AdaptivePartitioner>
GTS_INLINE void operator() (TIter begin, TIter end, TFunc func, TPartitioner partitioner=TPartitioner())
 Applies the given function 'func' to the specified 1D iteration range [begin, end). Always uses an AdaptivePartitioner with a minimum block size of 1. More...
 

Detailed Description

A construct that maps parallel-for behavior to a MicroScheduler.

Constructor & Destructor Documentation

◆ ParallelFor()

GTS_INLINE gts::ParallelFor::ParallelFor ( MicroScheduler scheduler,
uint32_t  priority = 0 
)
inline

Creates a ParallelFor object bound to the specified 'scheduler'. All parallel-for operations will be scheduled with the specified 'priority'.

Member Function Documentation

◆ operator()() [1/2]

template<typename TIter , typename TFunc , typename TPartitioner = AdaptivePartitioner>
GTS_INLINE void gts::ParallelFor::operator() ( TIter  begin,
TIter  end,
TFunc  func,
TPartitioner  partitioner = TPartitioner() 
)
inline

Applies the given function 'func' to the specified 1D iteration range [begin, end). Always uses an AdaptivePartitioner with a minimum block size of 1.

Parameters
funcThe function to apply to each element of range. Signature:
void(*)(TIter iter, void* pUserData, TaskContext const&);

◆ operator()() [2/2]

template<typename TPartitioner , typename TRange , typename TFunc >
GTS_INLINE void gts::ParallelFor::operator() ( TRange const &  range,
TFunc  func,
TPartitioner  partitioner,
void *  pUserData,
bool  block = true 
)
inline

Applies the given function 'func' to the specified iteration 'range'.

Parameters
rangeAn iteration range.
funcThe function to apply to each element of range. Signature:
void(*)(TRange& range, void* pUserData, TaskContext const&);
partitionerThe partitioner object that determines when work is subdivided during scheduling.
pUserDataOptional user data that will be passed into func.
blockFlag true to block until all ParallelFor tasks complete