Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::app::details::TrackedFuture Struct Reference

Tracked future with ready flag to reduce syscall churn. More...

#include <app.hpp>

Public Member Functions

void Wait ()
 Waits for the future to complete if not already ready.
 
bool IsReady () noexcept
 Checks if the future is ready, caching the result.
 
bool Valid () const noexcept
 Checks if the future is valid.
 

Public Attributes

std::shared_future< void > future
 The underlying future.
 
bool ready = false
 Cached ready state.
 

Detailed Description

Tracked future with ready flag to reduce syscall churn.

Wraps a shared_future with a cached ready flag to avoid repeated wait_for(0) calls. Once marked ready, no further syscalls are made to check status.

Definition at line 45 of file app.hpp.

Member Function Documentation

◆ IsReady()

bool helios::app::details::TrackedFuture::IsReady ( )
inlinenoexcept

Checks if the future is ready, caching the result.

Only makes a syscall if not already marked ready.

Returns
True if the future has completed
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 64 of file app.hpp.

64 {
65 if (ready) {
66 return true;
67 }
68 if (future.valid() && future.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
69 ready = true;
70 return true;
71 }
72 return false;
73 }
std::shared_future< void > future
The underlying future.
Definition app.hpp:46
bool ready
Cached ready state.
Definition app.hpp:47

◆ Valid()

bool helios::app::details::TrackedFuture::Valid ( ) const
inlinenoexcept

Checks if the future is valid.

Returns
True if the underlying future is valid
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 79 of file app.hpp.

79{ return future.valid(); }

◆ Wait()

void helios::app::details::TrackedFuture::Wait ( )
inline

Waits for the future to complete if not already ready.

Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 52 of file app.hpp.

52 {
53 if (!ready && future.valid()) {
54 future.wait();
55 ready = true;
56 }
57 }

Member Data Documentation

◆ future

std::shared_future<void> helios::app::details::TrackedFuture::future

The underlying future.

Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 46 of file app.hpp.

◆ ready

bool helios::app::details::TrackedFuture::ready = false