StaticJobGroupRef< T > Class Template Reference 线程

#include <jobgroup.h>

Inheritance diagram for StaticJobGroupRef< T >:

详细描述

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

Reference to a group with static maximum job count ( StaticJobGroupInterface ).

Public Types

using  ReferencedType = StaticJobGroupInterface < T >
-  Public Types inherited from BaseRef< T, HANDLER >
using  ReferencedType = T
using  ConstReferencedType = typename ConstIf < T, Bool (HANDLER::KIND & VALUEKIND::DEEP_CONSTNESS )>::type
using  DirectlyReferencedType = T
using  SelfType = BaseRef < T, HANDLER >
template<typename D >
using  IsGenericBaseOf = std::true_type
using  Handler = HANDLER
using  RefCompareType = RefCompare < MAXON_IS_COW_KIND (HANDLER::KIND), IsInterfaceType < T >::value >

公共成员函数

  MAXON_DEFAULT_REFERENCE_CONSTRUCTORS ( StaticJobGroupRef , Ptr )
void  添加 ( StaticJobArray < T > &jobs)
StaticJobGroupRef < T > &  Enqueue ( 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
ObservableFinishedBase< JobGroupInterface ObservableFinished ()
void  取消 ()
void  CancelAndWait ( WAITMODE mode= WAITMODE::DEFAULT )
  operator JobGroupRef & ()
String   ToString (const FormatStatement *formatStatement=nullptr) const
-  Public Member Functions inherited from BaseRef< T, HANDLER >
T *  GetPointer ()
ConstReferencedType GetPointer () const
T *  operator-> ()
ConstReferencedType operator-> () const
T &  operator* ()
ConstReferencedType operator* () const
  operator T* ()
  operator ConstReferencedType * () const
  operator Bool () const
  operator Bool ()
const T &  operator[] ( Int ) const =delete
ResultRef < typename std::remove_const< T >::type >  MakeWritable ( Bool resetOnError=true)
T &  GetOrNull () const
  BaseRef ()
MAXON_IMPLICIT   BaseRef (std::nullptr_t)=delete
MAXON_IMPLICIT   BaseRef (T *o)
template<typename PTR >
  BaseRef ( ForwardResultPtr < PTR > o)
  BaseRef ( ResultPtr < T > o, Int )
  BaseRef (const BaseRef & src )
template<typename REF , typename = typename std::enable_if<!STD_IS_REPLACEMENT(base_of, BaseRef, REF) && maxon::HasErasedBase<typename REF::ReferencedType, ReferencedType>::value>::type>
MAXON_IMPLICIT   BaseRef (const REF & src )
template<typename REF , typename = typename std::enable_if<!STD_IS_REPLACEMENT(base_of, BaseRef, REF) && maxon::HasErasedBase<typename REF::ReferencedType, ReferencedType>::value>::type>
MAXON_IMPLICIT   BaseRef (REF & src )
BaseRef operator= (T * src )
BaseRef operator= (std::nullptr_t src )
BaseRef operator= (const BaseRef & src )
template<typename REF , typename = typename std::enable_if<!STD_IS_REPLACEMENT(base_of, BaseRef, REF) && maxon::HasErasedBase<typename REF::ReferencedType, ReferencedType>::value>::type>
BaseRef operator= (const REF & src )
template<typename REF , typename = typename std::enable_if<!STD_IS_REPLACEMENT(base_of, BaseRef, REF) && maxon::HasErasedBase<typename REF::ReferencedType, ReferencedType>::value>::type>
BaseRef operator= (REF & src )
  BaseRef ( BaseRef && src )
template<typename REF , typename = typename std::enable_if<!STD_IS_REPLACEMENT(const, REF) && !STD_IS_REPLACEMENT(base_of, BaseRef, REF) && maxon::HasErasedBase<typename REF::ReferencedType, ReferencedType>::value>::type>
MAXON_IMPLICIT   BaseRef (REF && src )
BaseRef operator= ( BaseRef && src )
template<typename REF , typename = typename std::enable_if<!STD_IS_REPLACEMENT(const, REF) && !STD_IS_REPLACEMENT(base_of, BaseRef, REF) && maxon::HasErasedBase<typename REF::ReferencedType, ReferencedType>::value>::type>
BaseRef operator= (REF && src )
  ~BaseRef ()
Bool   operator== (const BaseRef &b) const
Bool   operator!= (const BaseRef &b) const
Bool   operator== (const T *b) const
Bool   operator!= (const T *b) const
Bool   operator== (typename std::remove_const< T >::type *b) const
Bool   operator!= (typename std::remove_const< T >::type *b) const
Bool   operator== (std::nullptr_t) const
Bool   operator!= (std::nullptr_t) const
HashInt   GetHashCode () const
T *  Disconnect ()
void  PrivateSetTarget ( ResultPtr < T > src )
void  PrivateSetPointer (T *ptr)

静态公共成员函数

static ResultMemT < StaticJobGroupRef 创建 ( Int jobCnt, STATICJOBGROUPFLAGS flags= STATICJOBGROUPFLAGS::DEFAULT , Int extraBufferSize=0)
static const StaticJobGroupRef NullValue ()
-  Static Public Member Functions inherited from BaseRef< T, HANDLER >
static std::false_type  GenericVarianceCheck (const void *)
template<typename... ARGS>
static MAXON_ATTRIBUTE_FORCE_INLINE ResultMemT < BaseRef 创建 (ARGS &&... args)
static const BaseRef NullValueRef ()
static std::conditional< Bool (HANDLER::KIND & VALUEKIND::UNIQUE_REFERENCE ), BaseRef , const BaseRef & >::type  NullValue ()

Private Types

using  Ptr = StrongRef < StaticJobGroupInterface < T > >

Additional Inherited Members

-  Static Public Attributes inherited from BaseRef< T, HANDLER >
static const Bool   DIRECT_REF
-  Protected Attributes inherited from BaseRef< T, HANDLER >
T *  _object

Member Typedef Documentation

◆  Ptr

using Ptr = StrongRef < StaticJobGroupInterface <T> >
private

◆  ReferencedType

using ReferencedType = StaticJobGroupInterface <T>

成员函数文档编制

◆  MAXON_DEFAULT_REFERENCE_CONSTRUCTORS()

MAXON_DEFAULT_REFERENCE_CONSTRUCTORS ( StaticJobGroupRef < T >  ,
Ptr    
)

◆  Create()

static ResultMemT < StaticJobGroupRef > Create ( Int   jobCnt ,
STATICJOBGROUPFLAGS   flags = STATICJOBGROUPFLAGS::DEFAULT ,
Int   extraBufferSize = 0  
)
static

Creates a StaticJobGroup.

参数
[in] jobCnt The maximum number of jobs for this group.
[in] flags STATICJOBGROUPFLAGS::DEFAULT by default, the other custom modes are for ParallelFor only.
[in] extraBufferSize By default 0. Size of a private buffer that can be allocated together with the group.
返回
StaticJobGroupRef on success, OutOfMemoryerror on failure.

◆  Add()

void Add ( StaticJobArray < T > &  jobs )

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

参数
[in] jobs A StaticJobArray that was initialized with this group.

◆  Enqueue()

StaticJobGroupRef <T>& Enqueue ( JobQueueInterface queue = JOBQUEUE_CURRENT )

Enqueues all jobs of the group including subgroups (will add a reference and remove it when the object is no longer needed). THREADSAFE.

参数
[in] queue The queue, use JOBQUEUE_CURRENT for the current queue.
返回
Always reference to itself (for concatenation).

◆  EnqueueAndWait()

Result <void> EnqueueAndWait ( JobQueueInterface queue = JOBQUEUE_CURRENT )

Enqueues all jobs of the group including subgroups and waits for them. This implicitely indicates to the system that the current job cannot continue until the group has finished. THREADSAFE.

参数
[in] queue The queue, use JOBQUEUE_CURRENT for the current queue.
返回
OK on success.

◆  Wait()

Bool Wait ( TimeValue   timeout = TIMEVALUE_INFINITE ,
WAITMODE   mode = WAITMODE::DEFAULT  
) const

Waits until all jobs of the group have been executed.

Wait() might execute other jobs in the current queue until the group you are waiting for has finished or is timed out. Therefore you may never lock a shared resource another job might use as well and then wait. For one this could dead-lock and conceptually this would result in single-threaded performance.

If you try to call Wait() from a job which did not enqueue the group it will immediately return false because this would lead to a deadlock.

Instead of waiting for some group to start some action after it has finished you can subscribe to ObservableFinished() . This cannot dead-lock, is more efficient and can even be used to run the observer in a different queue. For example you can run a job and register an observer for it that will run on the main thread's queue and updates the UI. THREADSAFE.

参数
[in] timeout Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
[in] mode WAITMODE::DEFAULT by default. WAITMODE::RETURN_ON_CANCEL means that Wait() will return if the caller has been cancelled even if the condition has not been set yet.
返回
True if successful, false if you try to wait inside an enqueued job.

◆  GetResult()

Result <void> GetResult ( TimeValue   timeout = TIMEVALUE_INFINITE ,
WAITMODE   mode = WAITMODE::DEFAULT  
) const

Waits until the group has been executed and returns OK on success or any errors returned by its jobs. If there are errors this might return an AggregatedError . THREADSAFE.

参数
[in] timeout Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
[in] mode WAITMODE::DEFAULT by default. WAITMODE::RETURN_ON_CANCEL means that Wait() will return if the caller has been cancelled even if the condition has not been set yet.
返回
OK on success.

◆  ObservableFinished()

ObservableFinishedBase< JobGroupInterface > ObservableFinished ( )

ObservableFinished is an observable that is triggered after this group has been executed. THREADSAFE.

返回
Custom observable.

◆  Cancel()

void Cancel ( )

Asks the group to cancel execution of all jobs that are enqueued. Currently running jobs are not affected unless they call IsCancelled(). If this is a subgroup the parent group will be cancelled too. The call will not wait for the group to cancel and it can be called from any thread or job. THREADSAFE.

◆  CancelAndWait()

void CancelAndWait ( WAITMODE   mode = WAITMODE::DEFAULT )

Asks the group to cancel execution and waits until it has finished. THREADSAFE.

参数
[in] mode WAITMODE::DEFAULT by default.

◆  operator JobGroupRef &()

operator JobGroupRef & ( )

Returns a more generic JobGroupRef . THREADSAFE.

返回
Cast to JobGroupRef .

◆  NullValue()

static const StaticJobGroupRef & NullValue ( )
static

Returns a null value of the StaticJobGroupRef (见 nullvalue.h for more details).

返回
A null value of the StaticJobGroupRef .

◆  ToString()

String ToString ( const FormatStatement formatStatement = nullptr ) const

Returns a readable string of the content.

参数
[in] formatStatement Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
返回
The converted result.