Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Raven::DeferredExecutionQueue Class Reference

Manages deferred execution of callbacks. More...

#include <DeferredDeletionQueue.h>

Public Types

using ExecutionFn = FixedFunction<void()>
 Move-only callable representing a execution.
using PredicateFn = FixedFunction<bool()>
 Move-only callable returning a boolean condition.

Public Member Functions

 DeferredExecutionQueue (u32 framesInFlight=3) noexcept
 Construct a deferred execution queue.
 ~DeferredExecutionQueue () noexcept
 Destructs the queue and flushes all pending executions.
 DeferredExecutionQueue (const DeferredExecutionQueue &)=delete
DeferredExecutionQueueoperator= (const DeferredExecutionQueue &)=delete
void EnqueueAfterFrames (ExecutionFn fn, uint32_t delay=0) noexcept
 Enqueue a execution to occur after delay frames.
void EnqueueWhen (PredicateFn predicate, ExecutionFn fn) noexcept
 Enqueue a execution that occurs when a predicate returns true.
void OnFrameEnd () noexcept
 Advance the frame counter and execute ready executions.
void Process () noexcept
 Process only predicate-based executions.
void Flush () noexcept
 Immediately execute all pending executions and clear the queue.
u32 FramesInFlight () const noexcept

Detailed Description

Manages deferred execution of callbacks.

Designed primarily for GPU resources, but can manage any deferred cleanup. Provides frame-based delays and predicate-based conditional execution.

Member Typedef Documentation

◆ ExecutionFn

Move-only callable representing a execution.

◆ PredicateFn

Move-only callable returning a boolean condition.

Constructor & Destructor Documentation

◆ DeferredExecutionQueue() [1/2]

Raven::DeferredExecutionQueue::DeferredExecutionQueue ( u32 framesInFlight = 3)
inlineexplicitnoexcept

Construct a deferred execution queue.

Parameters
framesInFlightNumber of frames in flight to account for.

Internally allocates a ring buffer of size framesInFlight + 1. framesInFlight must be at least 1.

◆ ~DeferredExecutionQueue()

Raven::DeferredExecutionQueue::~DeferredExecutionQueue ( )
inlinenoexcept

Destructs the queue and flushes all pending executions.

◆ DeferredExecutionQueue() [2/2]

Raven::DeferredExecutionQueue::DeferredExecutionQueue ( const DeferredExecutionQueue & )
delete

Member Function Documentation

◆ EnqueueAfterFrames()

void Raven::DeferredExecutionQueue::EnqueueAfterFrames ( ExecutionFn fn,
uint32_t delay = 0 )
inlinenoexcept

Enqueue a execution to occur after delay frames.

Parameters
fnexecution callable.
delayNumber of frames to wait (0 -> next OnFrameEnd).

Typically used for GPU resources to ensure they outlive all frames in flight.

◆ EnqueueWhen()

void Raven::DeferredExecutionQueue::EnqueueWhen ( PredicateFn predicate,
ExecutionFn fn )
inlinenoexcept

Enqueue a execution that occurs when a predicate returns true.

Parameters
predicateCondition callable, polled each frame.
fnexecution callable executed once predicate returns true.

◆ Flush()

void Raven::DeferredExecutionQueue::Flush ( )
inlinenoexcept

Immediately execute all pending executions and clear the queue.

Typically used at shutdown to ensure no resource leaks.

◆ FramesInFlight()

u32 Raven::DeferredExecutionQueue::FramesInFlight ( ) const
inlinenoexcept
Returns
Number of frames in flight tracked by this queue.

◆ OnFrameEnd()

void Raven::DeferredExecutionQueue::OnFrameEnd ( )
inlinenoexcept

Advance the frame counter and execute ready executions.

Call once per frame at a safe point (e.g., after GPU submission). Processes frame-delayed executions and predicate-based executions.

◆ operator=()

DeferredExecutionQueue & Raven::DeferredExecutionQueue::operator= ( const DeferredExecutionQueue & )
delete

◆ Process()

void Raven::DeferredExecutionQueue::Process ( )
inlinenoexcept

Process only predicate-based executions.

Can be called independently if frame advancement is separate.


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