StaticJobGroupInterface< T > Class Template Reference

#include <jobgroup.h>

Inheritance diagram for StaticJobGroupInterface< T >:

Detailed Description

template<typename T>
class maxon::StaticJobGroupInterface< T >

This is a template for homogenous static job group: All job of the same type and the number of jobs is known at creation. Once you have allocated a StaticJobGroup you cannot add more than the number of jobs specified and you cannot add jobs of a different type than specified in the template. Nonetheless you can add as many subgroups as you want.

Public Member Functions

void Add (StaticJobArray< T > &jobs)
 
String ToString (const FormatStatement *formatStatement=nullptr) const
 
Result< void > Add (JobInterface *job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
Result< void > Add (JobRef &job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
template<typename T >
Result< void > Add (ResultMemT< T * > job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
template<typename JOBREF >
Result< void > Add (ResultMemT< JOBREF > &&job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
- Public Member Functions inherited from JobGroupInterface
JobGroupInterfaceEnqueue (JobQueueInterface *queue=JOBQUEUE_CURRENT)
 
Result< void > EnqueueAndWait (JobQueueInterface *queue=JOBQUEUE_CURRENT)
 
Bool Wait (TimeValue timeout=TIMEVALUE_INFINITE, WAITMODE mode=WAITMODE::DEFAULT) const
 
Result< void > GetResult (TimeValue timeout=TIMEVALUE_INFINITE, WAITMODE mode=WAITMODE::DEFAULT) const
 
Result< void > Add (JobInterface *job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
Result< void > Add (JobRef &job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
template<typename T >
Result< void > Add (ResultMemT< T * > job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
template<typename JOBREF >
Result< void > Add (ResultMemT< JOBREF > &&job, JOBGROUPADDFLAGS flags=JOBGROUPADDFLAGS::DEFAULT)
 
template<JOBCANCELLATION B = JOBCANCELLATION::ISOK, typename FN >
 DISABLE_IF_JOB_OR_GROUP (FN, Result< void >) Add(FN &&src
 

Static Public Member Functions

static ResultPtr< StaticJobGroupInterfaceAlloc (Int jobCnt, STATICJOBGROUPFLAGS flags=STATICJOBGROUPFLAGS::DEFAULT, Int extraBufferSize=0)
 
static ResultPtr< StaticJobGroupInterfaceAlloc (JobQueueInterface *queue, Int &threadCnt, STATICJOBGROUPFLAGS flags=STATICJOBGROUPFLAGS::DEFAULT, Int extraBufferSize=0)
 

Private Member Functions

 ~StaticJobGroupInterface ()
 

Additional Inherited Members

- Public Attributes inherited from JobGroupInterface
JOBGROUPADDFLAGS flags
 

Constructor & Destructor Documentation

◆ ~StaticJobGroupInterface()

Member Function Documentation

◆ Add() [1/5]

void Add ( StaticJobArray< T > &  jobs)

Adds an array with multiple jobs of the same type to the group (faster than single Add()s).

Parameters
[in]jobsA StaticJobArray that was initialized with this group.

◆ Alloc() [1/2]

static ResultPtr<StaticJobGroupInterface> Alloc ( Int  jobCnt,
STATICJOBGROUPFLAGS  flags = STATICJOBGROUPFLAGS::DEFAULT,
Int  extraBufferSize = 0 
)
static

Allocates a StaticJobGroup.

Parameters
[in]jobCntThe maximum number of jobs for this group.
[in]flagsSTATICJOBGROUPFLAGS::DEFAULT by default, the other custom modes are for ParallelFor only.
[in]extraBufferSizeBy default 0. Size of a private buffer that can be allocated together with the group.
Returns
StaticJobGroupInterface pointer or nullptr if allocation failed.

◆ Alloc() [2/2]

static ResultPtr<StaticJobGroupInterface> Alloc ( JobQueueInterface queue,
Int threadCnt,
STATICJOBGROUPFLAGS  flags = STATICJOBGROUPFLAGS::DEFAULT,
Int  extraBufferSize = 0 
)
static

◆ ToString()

String ToString ( const FormatStatement formatStatement = nullptr) const

Returns a readable string of the content.

Parameters
[in]formatStatementNullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
Returns
The converted result.

◆ Add() [2/5]

Result<void> Add

Adds a job to the group. The group takes exclusive ownership of the job. The job will be deleted after it has been executed, when the group will be deleted or when adding the job fails. The job must have been created using DefaultAllocator, e.g. with Create() or NewObj(). If you had created a job on the stack or used a custom allocator this would lead to a crash. As long as the group is not enqueued you can add jobs from any thread. As soon as it is enqueued only jobs belonging to the group are allowed to add further jobs. THREADSAFE.

Parameters
[in]jobJob (nullptr will return error).
Returns
OK on success.

◆ Add() [3/5]

Result<void> Add

Adds a job to the group. The group takes exclusive ownership of the job. The job will be deleted after it has been executed, when the group will be deleted or when adding the job fails. The job must have been created using DefaultAllocator, e.g. with Create() or NewObj(). If you had created a job on the stack or used a custom allocator this would lead to a crash. As long as the group is not enqueued you can add jobs from any thread. As soon as it is enqueued only jobs belonging to the group are allowed to add further jobs. THREADSAFE.

Parameters
[in]jobJob (nullptr will return error).
Returns
OK on success.

◆ Add() [4/5]

Result<void> Add ( typename T  )

Adds a job to the group. The group takes exclusive ownership of the job. The job will be deleted after it has been executed, when the group will be deleted or when adding the job fails. The job must have been created using DefaultAllocator, e.g. with Create() or NewObj(). If you had created a job on the stack or used a custom allocator this would lead to a crash. As long as the group is not enqueued you can add jobs from any thread. As soon as it is enqueued only jobs belonging to the group are allowed to add further jobs. THREADSAFE.

Parameters
[in]jobJob (encapsulated in a ResultMemT directly returned from creation).
Returns
OK on success.

◆ Add() [5/5]

Result<void> Add ( typename JOBREF  )

Adds a job to the group. The group takes exclusive ownership of the job. The job will be deleted after it has been executed, when the group will be deleted or when adding the job fails. The job must have been created using DefaultAllocator, e.g. with Create() or NewObj(). If you had created a job on the stack or used a custom allocator this would lead to a crash. As long as the group is not enqueued you can add jobs from any thread. As soon as it is enqueued only jobs belonging to the group are allowed to add further jobs. THREADSAFE.

Parameters
[in]jobJob (encapsulated in a ResultMemT directly returned from creation).
Returns
OK on success.