ParallelFor::BaseContext Class Reference

#include <parallelfor.h>

Inheritance diagram for ParallelFor::BaseContext:

详细描述

Basic context for ParallelFor loops. Each worker thread has its own local context.

Public Types

using  ResultValueType = void

公共成员函数

  BaseContext ()
template<typename INDEXTYPE >
void  PrivateInit (INDEXTYPE from, INDEXTYPE to, Int threadIndex, BreakCondition *breakCondition)
template<typename FN , typename CONTEXT , typename INDEXTYPE >
void  Invoke (FN &obj, INDEXTYPE i)
Bool   IsCancelled () const
Int   GetWorkerThreadIndex () const
void  UpdateWorkerThreadIndex ( Int threadIndex= JobRef::GetCurrentWorkerThreadIndex ())
Int   GetLocalThreadIndex () const
void  Break ( Result < void > result= OK )

静态公共成员函数

static ResultValueType   返回 ( Result < void > &&r)

Public Attributes

Int   _from
Int   _to
Int   _workerThreadIndex
Int   _localContextIndex
Result < void >  _result
BreakCondition _breakCondition

私有成员函数

  MAXON_DISALLOW_COPY_AND_ASSIGN ( BaseContext )

Member Typedef Documentation

◆  ResultValueType

using ResultValueType = void

构造函数 & 析构函数文档编制

◆  BaseContext()

BaseContext ( )

成员函数文档编制

◆  PrivateInit()

void PrivateInit ( INDEXTYPE  from ,
INDEXTYPE  to ,
Int   threadIndex ,
BreakCondition breakCondition  
)

Intializes the custom user data for a complex loop.

参数
[in] from Start index.
[in] to End index (excluded)
[in] threadIndex Initial thread index.
[in] breakCondition Pointer to a BreakCondition or nullptr (break not supported by context).

◆  Invoke()

void Invoke ( FN &  obj ,
INDEXTYPE  i  
)

Invokes the loop body object.

参数
[in] obj Reference to loop body object.
[in] i Index.
Template Parameters
FN A class containing an operator ()(INDEXTYPE) used for the loop.
CONTEXT Type of context super class.
INDEXTYPE An integral type used for the index of the loop.

◆  IsCancelled()

Bool IsCancelled ( ) const

Returns true if the loop should be quit.

返回
Always return false so that the compiler can remove unnecessary compares and jumps.

◆  GetWorkerThreadIndex()

Int GetWorkerThreadIndex ( ) const

Returns the index of the worker thread. This is the same value as returned by JobRef::GetCurrentWorkerThreadIndex() (but with less overhead) and is guaranteed to be identical for nested ParallelFors on the same worker thread. The worker thread index might be greater than the number of threads you specified because your code will be scheduled to run on the first available thread of the queue.

返回
Worker thread index (between 0 and number of worker threads for the queue - 1).

◆  UpdateWorkerThreadIndex()

void UpdateWorkerThreadIndex ( Int   threadIndex = JobRef::GetCurrentWorkerThreadIndex() )

Updates the worker thread index once a loop is a started on a job.

◆  GetLocalThreadIndex()

Int GetLocalThreadIndex ( ) const

Returns a local thread index between 0 and the the number of threads requested - 1. The value is different from GetWorkerThreadIndex() /GetCurrentWorkerThreadIndex() and for nested ParallelFors it can be different on the same worker thread.

返回
Local thread index (between 0 and number of requested threads - 1).

◆  Break()

void Break ( Result < void >  result = OK )

Does nothing (use BreakContext ).

参数
[in] result Used to return an optional error.

◆  Return()

static ResultValueType 返回 ( Result < void > &&  r )
static

Ignores the result of the StaticJobGroup because it cannot fail (and the loop body returns void).

◆  MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( BaseContext   )
private

Member Data Documentation

◆  _from

Int _from

◆  _to

Int _to

◆  _workerThreadIndex

Int _workerThreadIndex

◆  _localContextIndex

Int _localContextIndex

◆  _result

Result <void> _result

◆  _breakCondition

BreakCondition * _breakCondition