Apparatus
Version 1.23
ECS data-oriented workflow for Unreal Engine.
|
Common chain functionality. More...
#include <CommonChain.h>
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 | |
AMechanism * | GetOwner () const |
Get the owning mechanism of the chain. | |
const FFilter & | GetFilter () 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 | |
AMechanism * | Owner = nullptr |
The owner of the chain. | |
int32 | Id = InvalidId |
A unique identifier of the chain. | |
std::atomic< UsersCountValueType > | UsersCount {0} |
The number of users currently needing the chain. | |
std::atomic< bool > | bDisposed {true} |
Was this chain disposed and ready to be reused? | |
std::atomic< bool > | bDisposing {false} |
Is the chain currently being disposed? | |
std::atomic< bool > | bStopIterating {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< OperatingsCountValueType > | OperatingsCount {0} |
The number of current operatings on the chain. | |
std::atomic< ConcurrencyLevelValueType > | ConcurrencyLevel {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 |
Common chain functionality.
Contains the basic functionality universal for all of the chains.
|
protected |
The type of the concurrency value.
|
protected |
The type of the value for the number of operatings within the chain.
|
protected |
The type of the number of chain users value.
anonymous enum |
|
inlinevirtual |
Finalize the chain.
Always call the Dispose() method in the descendants in order to wait properly.
|
inlineprotected |
Initialize a chain using its owning mechanism.
InOwner | The owning mechanism. |
|
inlineprotected |
Check if a chain can be reused as a new chain.
This mainly means that the embedded chain is disposed.
|
protected |
|
protected |
|
protected |
Reset the state of the chain and mark as disposed (ready to be reused).
bWaitForOperatings | Should the operation wait till all the operatings are complete. |
|
inline |
Get the current filter used to enchain the iterables.
|
inline |
Get the owning mechanism of the chain.
|
protected |
|
protected |
|
inline |
Check if the chain is disposed and is ready to be reused.
|
inline |
Get the number of current operatings happening within the chain.
Each mechanism also has its own local AMechanism::OperatingsNum().
|
inline |
Remove a user of the chain.
This can possibly trigger the chain disposal.
|
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.
bWaitForOperatings | Should the operation wait till all the operatings are complete. |
Reimplemented in TChain< ChunkItT, BeltItT, InDefaultParadigm >.
|
inline |
Add a user of the chain preventing it from being disposed.
|
inline |
Check if the chain should stop iterating.
|
inline |
Stop the current iterating of the chain (if any).
|
inline |
Convert the chain to a textual representation.
|
inline |
Get the current number of users of the chain.
The operation is thread-safe.
|
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().
|
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().
WaitTime | The time to wait. |
bIgnoreThreadIdleStats | If true , ignores ThreadIdleStats |
true
if the event was triggered, false
if the wait timed out.
|
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().
WaitTimeMsec | The time to wait. Measured in milliseconds. |
bIgnoreThreadIdleStats | If true , ignores ThreadIdleStats . |
true
if the event was triggered, false
if the wait timed out.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
mutableprotected |
The list of enqueued runnable mechanics.
This ensures that all of the runnables get executed to the end.
|
mutableprotected |
A critical section for the TChain::BackgroundRunnableMechanics access.
|
protected |
Was this chain disposed and ready to be reused?
|
protected |
Is the chain currently being disposed?
The flag is to prevent unnecessary recursion of the disposal procedure.
|
protected |
Are we currently in a destructor?
|
protected |
Should delete itself on disposal.
|
mutableprotected |
Was this chain stopped from further iterating?
|
mutableprotected |
The current concurrency level of the chain.
|
protected |
A filter under which the iterables are locked within the chain.
|
protected |
A unique identifier of the chain.
Should be valid only for mechanism-embedded chains.
|
mutableprotected |
The event is fired once all of the operatings are completed.
|
mutableprotected |
The number of current operatings on the chain.
This is atomic cause the concurrent operatings are added up to this value.
|
protected |
The owner of the chain.
Must be set during the initialization.
|
mutableprotected |
The number of users currently needing the chain.
If it becomes zero the chain is disposed.