Apparatus Version 1.23
ECS data-oriented workflow for Unreal Engine.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
FCommonChain Struct Reference

Common chain functionality. More...

#include <CommonChain.h>

Inheritance diagram for FCommonChain:
Inheritance graph
[legend]
Collaboration diagram for FCommonChain:
Collaboration graph
[legend]

Classes

struct  FCommonCursor
 Common chain cursor functionality. More...
 
struct  FCommonRunnableMechanic
 The common runnable mechanic base. More...
 
struct  TCommonMechanicTask
 A common asynchronous task. More...
 
struct  TCommonRunnableMechanic
 The runnable mechanical wrapping. More...
 
struct  TSegment
 The common functionality for a single iterable entry within the chain. More...
 

Public Types

enum  {
  InvalidId = -1 , InvalidSlotIndex = -1 , FirstId = 0 , InvalidCursorId = -1 ,
  DefaultCursorId = 0 , InvalidSegmentIndex = -1
}
 

Public Member Functions

AMechanismGetOwner () const
 Get the owning mechanism of the chain.
 
const FFilterGetFilter () const
 Get the current filter used to enchain the iterables.
 
bool IsDisposed () const
 Check if the chain is disposed and is ready to be reused.
 
int32 UsersNum () const
 Get the current number of users of the chain.
 
void Retain () const
 Add a user of the chain preventing it from being disposed.
 
void Release () const
 Remove a user of the chain.
 
virtual EApparatusStatus Reset (bool bWaitForOperatings=true)
 Reset the chain.
 
bool ShouldStopIterating () const
 Check if the chain should stop iterating.
 
EApparatusStatus StopIterating () const
 Stop the current iterating of the chain (if any).
 
auto OperatingsNum () const
 Get the number of current operatings happening within the chain.
 
void WaitForOperatingsCompletion () const
 Wait for all the current operatings to be completed.
 
bool WaitForOperatingsCompletion (const uint32 WaitTimeMsec, const bool bIgnoreThreadIdleStats=false) const
 Wait for all the current operatings to be completed.
 
bool WaitForOperatingsCompletion (const FTimespan &WaitTime, const bool bIgnoreThreadIdleStats=false) const
 Wait for all the current operatings to be completed.
 
virtual ~FCommonChain ()
 Finalize the chain.
 
Conversion
FString ToString () const
 Convert the chain to a textual representation.
 

Protected Types

using UsersCountValueType = uint8
 The type of the number of chain users value.
 
using OperatingsCountValueType = uint8
 The type of the value for the number of operatings within the chain.
 
using ConcurrencyLevelValueType = uint8
 The type of the concurrency value.
 

Protected Member Functions

bool CanBeReused () const
 Check if a chain can be reused as a new chain.
 
void IncrementConcurrencyLevel () const
 
void DecrementConcurrencyLevel () const
 
void IncrementOperatingsCount () const
 
void DecrementOperatingsCount () const
 
EApparatusStatus Dispose (bool bWaitForOperatings=true)
 Reset the state of the chain and mark as disposed (ready to be reused).
 
 FCommonChain (AMechanism *const InOwner)
 Initialize a chain using its owning mechanism.
 

Protected Attributes

AMechanismOwner = nullptr
 The owner of the chain.
 
int32 Id = InvalidId
 A unique identifier of the chain.
 
std::atomic< UsersCountValueTypeUsersCount {0}
 The number of users currently needing the chain.
 
std::atomic< boolbDisposed {true}
 Was this chain disposed and ready to be reused?
 
std::atomic< boolbDisposing {false}
 Is the chain currently being disposed?
 
std::atomic< boolbStopIterating {false}
 Was this chain stopped from further iterating?
 
FFilter Filter
 A filter under which the iterables are locked within the chain.
 
bool bSelfDestroyOnDisposal = false
 Should delete itself on disposal.
 
bool bInDestructor = false
 Are we currently in a destructor?
 
std::atomic< OperatingsCountValueTypeOperatingsCount {0}
 The number of current operatings on the chain.
 
std::atomic< ConcurrencyLevelValueTypeConcurrencyLevel {0}
 The current concurrency level of the chain.
 
FEventRef OperatingsCompleted {EEventMode::ManualReset}
 The event is fired once all of the operatings are completed.
 
TArray< TUniquePtr< FCommonRunnableMechanic > > BackgroundRunnableMechanics
 The list of enqueued runnable mechanics.
 
FCriticalSection BackgroundRunnableMechanicsCS
 A critical section for the TChain::BackgroundRunnableMechanics access.
 

Friends

class UApparatusFunctionLibrary
 
class AMechanism
 
class UMachine
 
template<typename... Ps>
struct TCursor
 
template<typename MechanicT , typename... Ps>
struct TRunnableMechanic
 

Detailed Description

Common chain functionality.

Contains the basic functionality universal for all of the chains.

Member Typedef Documentation

◆ ConcurrencyLevelValueType

using FCommonChain::ConcurrencyLevelValueType = uint8
protected

The type of the concurrency value.

◆ OperatingsCountValueType

using FCommonChain::OperatingsCountValueType = uint8
protected

The type of the value for the number of operatings within the chain.

◆ UsersCountValueType

using FCommonChain::UsersCountValueType = uint8
protected

The type of the number of chain users value.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
InvalidId 

Invalid chain identifier.

InvalidSlotIndex 

Invalid slot index.

FirstId 

First valid chain identifier.

InvalidCursorId 

Invalid cursor identifier.

DefaultCursorId 

Default cursor identifier.

InvalidSegmentIndex 

Invalid segment index.

Constructor & Destructor Documentation

◆ ~FCommonChain()

virtual FCommonChain::~FCommonChain ( )
inlinevirtual

Finalize the chain.

Always call the Dispose() method in the descendants in order to wait properly.

◆ FCommonChain()

FCommonChain::FCommonChain ( AMechanism *const  InOwner)
inlineprotected

Initialize a chain using its owning mechanism.

Parameters
InOwnerThe owning mechanism.

Member Function Documentation

◆ CanBeReused()

bool FCommonChain::CanBeReused ( ) const
inlineprotected

Check if a chain can be reused as a new chain.

This mainly means that the embedded chain is disposed.

Returns
The result of examination.

◆ DecrementConcurrencyLevel()

void FCommonChain::DecrementConcurrencyLevel ( ) const
protected

◆ DecrementOperatingsCount()

void FCommonChain::DecrementOperatingsCount ( ) const
protected

◆ Dispose()

EApparatusStatus FCommonChain::Dispose ( bool  bWaitForOperatings = true)
protected

Reset the state of the chain and mark as disposed (ready to be reused).

Parameters
bWaitForOperatingsShould the operation wait till all the operatings are complete.
Returns
The status of the operation.

◆ GetFilter()

const FFilter & FCommonChain::GetFilter ( ) const
inline

Get the current filter used to enchain the iterables.

◆ GetOwner()

AMechanism * FCommonChain::GetOwner ( ) const
inline

Get the owning mechanism of the chain.

Returns
The mechanism of the chain.

◆ IncrementConcurrencyLevel()

void FCommonChain::IncrementConcurrencyLevel ( ) const
protected

◆ IncrementOperatingsCount()

void FCommonChain::IncrementOperatingsCount ( ) const
protected

◆ IsDisposed()

bool FCommonChain::IsDisposed ( ) const
inline

Check if the chain is disposed and is ready to be reused.

Returns
The status of examination.

◆ OperatingsNum()

auto FCommonChain::OperatingsNum ( ) const
inline

Get the number of current operatings happening within the chain.

Note
This value can actually misrepresent the actual number if queried after the WaitForOperatingsCompletion(), cause the newly queued operations may already be altering it.

Each mechanism also has its own local AMechanism::OperatingsNum().

Returns
The current number of operatings within the chain.

◆ Release()

void FCommonChain::Release ( ) const
inline

Remove a user of the chain.

This can possibly trigger the chain disposal.

◆ Reset()

virtual EApparatusStatus FCommonChain::Reset ( bool  bWaitForOperatings = true)
inlinevirtual

Reset the chain.

All of the chain segments (iterables) get released as part of this operation.

The embedded cursors will get reset as well, but you have to release all of the manual users beforehand or otherwise the chain won't get disposed automatically.

Parameters
bWaitForOperatingsShould the operation wait till all the operatings are complete.
Returns
The status of the operation.

Reimplemented in TChain< ChunkItT, BeltItT, InDefaultParadigm >.

◆ Retain()

void FCommonChain::Retain ( ) const
inline

Add a user of the chain preventing it from being disposed.

◆ ShouldStopIterating()

bool FCommonChain::ShouldStopIterating ( ) const
inline

Check if the chain should stop iterating.

◆ StopIterating()

EApparatusStatus FCommonChain::StopIterating ( ) const
inline

Stop the current iterating of the chain (if any).

◆ ToString()

FString FCommonChain::ToString ( ) const
inline

Convert the chain to a textual representation.

Returns
The resulting textual representation.

◆ UsersNum()

int32 FCommonChain::UsersNum ( ) const
inline

Get the current number of users of the chain.

Note
Even an unused chain can be indisposed. This is by design and is needed to correctly initialize the chain.

The operation is thread-safe.

Returns
The current number of users of the chain.

◆ WaitForOperatingsCompletion() [1/3]

void FCommonChain::WaitForOperatingsCompletion ( ) const
inline

Wait for all the current operatings to be completed.

You can use this method after you queued up the asynchronous operatings in order to sync them all.

Each mechanism also has its own global AMechanism::WaitForOperatingsCompletion().

◆ WaitForOperatingsCompletion() [2/3]

bool FCommonChain::WaitForOperatingsCompletion ( const FTimespan &  WaitTime,
const bool  bIgnoreThreadIdleStats = false 
) const
inline

Wait for all the current operatings to be completed.

You can use this method after you queued up the asynchronous operatings in order to sync them all.

Each mechanism also has its own global AMechanism::WaitForOperatingsCompletion().

Parameters
WaitTimeThe time to wait.
bIgnoreThreadIdleStatsIf true, ignores ThreadIdleStats
Returns
true if the event was triggered, false if the wait timed out.

◆ WaitForOperatingsCompletion() [3/3]

bool FCommonChain::WaitForOperatingsCompletion ( const uint32  WaitTimeMsec,
const bool  bIgnoreThreadIdleStats = false 
) const
inline

Wait for all the current operatings to be completed.

You can use this method after you queued up the asynchronous operatings in order to sync them all.

Each mechanism also has its own global AMechanism::WaitForOperatingsCompletion().

Parameters
WaitTimeMsecThe time to wait. Measured in milliseconds.
bIgnoreThreadIdleStatsIf true, ignores ThreadIdleStats.
Returns
true if the event was triggered, false if the wait timed out.

Friends And Related Function Documentation

◆ AMechanism

friend class AMechanism
friend

◆ TCursor

template<typename... Ps>
friend struct TCursor
friend

◆ TRunnableMechanic

template<typename MechanicT , typename... Ps>
friend struct TRunnableMechanic
friend

◆ UApparatusFunctionLibrary

friend class UApparatusFunctionLibrary
friend

◆ UMachine

friend class UMachine
friend

Member Data Documentation

◆ BackgroundRunnableMechanics

TArray<TUniquePtr<FCommonRunnableMechanic> > FCommonChain::BackgroundRunnableMechanics
mutableprotected

The list of enqueued runnable mechanics.

This ensures that all of the runnables get executed to the end.

◆ BackgroundRunnableMechanicsCS

FCriticalSection FCommonChain::BackgroundRunnableMechanicsCS
mutableprotected

A critical section for the TChain::BackgroundRunnableMechanics access.

◆ bDisposed

std::atomic<bool> FCommonChain::bDisposed {true}
protected

Was this chain disposed and ready to be reused?

◆ bDisposing

std::atomic<bool> FCommonChain::bDisposing {false}
protected

Is the chain currently being disposed?

The flag is to prevent unnecessary recursion of the disposal procedure.

◆ bInDestructor

bool FCommonChain::bInDestructor = false
protected

Are we currently in a destructor?

◆ bSelfDestroyOnDisposal

bool FCommonChain::bSelfDestroyOnDisposal = false
protected

Should delete itself on disposal.

◆ bStopIterating

std::atomic<bool> FCommonChain::bStopIterating {false}
mutableprotected

Was this chain stopped from further iterating?

◆ ConcurrencyLevel

std::atomic<ConcurrencyLevelValueType> FCommonChain::ConcurrencyLevel {0}
mutableprotected

The current concurrency level of the chain.

◆ Filter

FFilter FCommonChain::Filter
protected

A filter under which the iterables are locked within the chain.

◆ Id

int32 FCommonChain::Id = InvalidId
protected

A unique identifier of the chain.

Should be valid only for mechanism-embedded chains.

◆ OperatingsCompleted

FEventRef FCommonChain::OperatingsCompleted {EEventMode::ManualReset}
mutableprotected

The event is fired once all of the operatings are completed.

◆ OperatingsCount

std::atomic<OperatingsCountValueType> FCommonChain::OperatingsCount {0}
mutableprotected

The number of current operatings on the chain.

This is atomic cause the concurrent operatings are added up to this value.

◆ Owner

AMechanism* FCommonChain::Owner = nullptr
protected

The owner of the chain.

Must be set during the initialization.

◆ UsersCount

std::atomic<UsersCountValueType> FCommonChain::UsersCount {0}
mutableprotected

The number of users currently needing the chain.

If it becomes zero the chain is disposed.


The documentation for this struct was generated from the following file: