![]() |
Raven Engine v0.1
|
Manages deferred execution of destruction callbacks. More...
#include <DeferredDeletionQueue.h>
Public Types | |
| using | DeletionFn = FixedFunction<void()> |
| Move-only callable representing a deletion. | |
| using | PredicateFn = FixedFunction<bool()> |
| Move-only callable returning a boolean condition. | |
Public Member Functions | |
| DeferredDeletionQueue (u32 framesInFlight=3) noexcept | |
| Construct a deferred deletion queue. | |
| ~DeferredDeletionQueue () noexcept | |
| Destructs the queue and flushes all pending deletions. | |
| DeferredDeletionQueue (const DeferredDeletionQueue &)=delete | |
| DeferredDeletionQueue & | operator= (const DeferredDeletionQueue &)=delete |
| void | EnqueueAfterFrames (DeletionFn fn, uint32_t delay=0) noexcept |
| Enqueue a deletion to occur after delay frames. | |
| void | EnqueueWhen (PredicateFn predicate, DeletionFn fn) noexcept |
| Enqueue a deletion that occurs when a predicate returns true. | |
| void | OnFrameEnd () noexcept |
| Advance the frame counter and execute ready deletions. | |
| void | Process () noexcept |
| Process only predicate-based deletions. | |
| void | Flush () noexcept |
| Immediately execute all pending deletions and clear the queue. | |
| u32 | FramesInFlight () const noexcept |
Manages deferred execution of destruction callbacks.
Designed primarily for GPU resources, but can manage any deferred cleanup. Provides frame-based delays and predicate-based conditional deletion.
| using Raven::DeferredDeletionQueue::DeletionFn = FixedFunction<void()> |
Move-only callable representing a deletion.
| using Raven::DeferredDeletionQueue::PredicateFn = FixedFunction<bool()> |
Move-only callable returning a boolean condition.
|
inlineexplicitnoexcept |
Construct a deferred deletion queue.
| framesInFlight | Number of frames in flight to account for. |
Internally allocates a ring buffer of size framesInFlight + 1. framesInFlight must be at least 1.
|
inlinenoexcept |
Destructs the queue and flushes all pending deletions.
|
delete |
|
inlinenoexcept |
Enqueue a deletion to occur after delay frames.
| fn | Deletion callable. |
| delay | Number of frames to wait (0 -> next OnFrameEnd). |
Typically used for GPU resources to ensure they outlive all frames in flight.
|
inlinenoexcept |
Enqueue a deletion that occurs when a predicate returns true.
| predicate | Condition callable, polled each frame. |
| fn | Deletion callable executed once predicate returns true. |
|
inlinenoexcept |
Immediately execute all pending deletions and clear the queue.
Typically used at shutdown to ensure no resource leaks.
|
inlinenoexcept |
|
inlinenoexcept |
Advance the frame counter and execute ready deletions.
Call once per frame at a safe point (e.g., after GPU submission). Processes frame-delayed deletions and predicate-based deletions.
|
delete |
|
inlinenoexcept |
Process only predicate-based deletions.
Can be called independently if frame advancement is separate.