ConditionVariableInterface Class Reference 线程

#include <conditionvariable.h>

详细描述

After the condition variable has been constructed its state will be cleared until Set() is called. This state is sticky until someone calls Clear() unless the condition variable has been created as auto-clear.

公共成员函数

MAXON_METHOD void  清零 ( Int32 dependencyCnt=1)
MAXON_METHOD void  AddDependency ()
MAXON_METHOD Bool   Set ()
MAXON_METHOD Bool   Wait (const TimeValue &timeout= TIMEVALUE_INFINITE , WAITMODE mode= WAITMODE::DEFAULT ) const
MAXON_FUNCTION ObservableFinishedBase < ConditionVariableInterface ObservableFinished ()

静态公共成员函数

static MAXON_METHOD ConditionVariableInterface Alloc ( MAXON_SOURCE_LOCATION_DECLARATION )
static MAXON_METHOD ConditionVariableInterface Alloc ( MAXON_SOURCE_LOCATION_DECLARATION , Bool isAutoClear)

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( ConditionVariableInterface , MAXON_REFERENCE_NORMAL , "net.maxon.interface.conditionvariable")
MAXON_METHOD Result < void >  PrivateAddFinishedObserver (const JobInterfacePOD &observerPod, JobQueueInterface *observerQueue)

Static Private Member Functions

static MAXON_FUNCTION Result < void >  AddFinishedObserver ( ConditionVariableInterface *cond, JobInterface *observer, JobQueueInterface *queue= JOBQUEUE_NONE )
template<typename T >
static MAXON_FUNCTION std::enable_if<! STD_IS_REPLACEMENT (convertible, typename std::remove_reference< T >::type, JobInterface *), Result < void > >::type  AddFinishedObserver ( ConditionVariableInterface *cond, T && src , JobQueueInterface *queue= JOBQUEUE_NONE )

Friends

template<typename >
struct  ObservableFinishedBase

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( ConditionVariableInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.interface.conditionvariable"   
)
private

◆  Alloc() [1/2]

static MAXON_METHOD ConditionVariableInterface * Alloc ( MAXON_SOURCE_LOCATION_DECLARATION   )
static
参数
[in] allocLocation Source location.

◆  Alloc() [2/2]

static MAXON_METHOD ConditionVariableInterface * Alloc ( MAXON_SOURCE_LOCATION_DECLARATION   ,
Bool   isAutoClear  
)
static

If at all times only one thread waits for a condition variable you can make it auto-clear. This means a Wait() call will automatically clear the condition variable upon return.

参数
[in] allocLocation Source location.
[in] isAutoClear True: Wait() will automatically clear the condition variable. False: The state is sticky until Clear() is called.

◆  Clear()

MAXON_METHOD void Clear ( Int32   dependencyCnt = 1 )

Clears the condition variable and sets the number of dependencies (the number of threads that have to call Set() before the condition is met). By default this is one. When Clear() is called after Wait() you must make sure that there are no more threads still waiting for the same condition. Only after the last thread has left Wait() you are allowed to call Clear() . Otherwise one of the threads may keep waiting because the condition was cleared before it was able to wake up.

参数
[in] dependencyCnt The number of times Set() has to be called before the waiting threads will be woken up.

◆  AddDependency()

MAXON_METHOD void AddDependency ( )

Adds another dependency to the condition, e.g. another thread that has to call Set() before the state is considered set. The condition state must not be set yet. This means you must call this from a thread which hasn't done its Set() call yet. THREADSAFE.

◆  Set()

MAXON_METHOD Bool Set ( )

Wakes up all threads waiting for this condition (if the dependency count reaches 0, see Clear() ). THREADSAFE.

返回
True if successful.

◆  Wait()

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

Waits until the condition has been set or a certain amount of time has passed. Does not execute other jobs on the current queue while waiting. Therefore waiting for a condition variable in a job might result in a deadlock. It's recommended to call this from a thread only - other uses (e.g. from a job) might be unsafe and dead-lock. 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 the condition has been set, false for time out or error.

◆  ObservableFinished()

MAXON_FUNCTION ObservableFinishedBase < ConditionVariableInterface > ObservableFinished ( )

ObservableFinished is an observable that is triggered after the condition is set. Is not supported for auto-clear because it requires a sticky state. THREADSAFE.

返回
Custom observable.

◆  PrivateAddFinishedObserver()

MAXON_METHOD Result <void> PrivateAddFinishedObserver ( const JobInterfacePOD &  observerPod ,
JobQueueInterface observerQueue  
)
private

◆  AddFinishedObserver() [1/2]

static MAXON_FUNCTION Result <void> AddFinishedObserver ( ConditionVariableInterface cond ,
JobInterface observer ,
JobQueueInterface queue = JOBQUEUE_NONE  
)
static private

◆  AddFinishedObserver() [2/2]

static MAXON_FUNCTION std::enable_if<! STD_IS_REPLACEMENT (convertible, typename std::remove_reference<T>::type, JobInterface *), Result <void> >::type AddFinishedObserver ( ConditionVariableInterface cond ,
T &&  src ,
JobQueueInterface queue = JOBQUEUE_NONE  
)
static private

Friends And Related Function Documentation

◆  ObservableFinishedBase

friend struct ObservableFinishedBase friend