Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::SchedJob Class Reference

Move-only wrapper for scheduler-owned ECS work. More...

#include <sched.h>

Public Member Functions

 SchedJob ()=default
 Creates an empty wrapper.
 
 SchedJob (Sched sched, SchedToken token, bool submitted, void *pCleanupCtx, void(*cleanup)(void *pCtx))
 Creates a wrapper around token from sched.
 
 ~SchedJob ()
 Waits for and deletes a still-owned token.
 
 SchedJob (const SchedJob &)=delete
 
SchedJoboperator= (const SchedJob &)=delete
 
 SchedJob (SchedJob &&other) noexcept
 Move-constructs a scheduler job wrapper.
 
SchedJoboperator= (SchedJob &&other) noexcept
 Move-assigns a scheduler job wrapper.
 
GAIA_NODISCARD bool valid () const
 Returns true if this wrapper owns scheduler work.
 
GAIA_NODISCARD SchedToken token () const
 Returns the opaque scheduler token.
 
void submit ()
 Submits the added work if it has not been submitted yet.
 
void dep (const SchedJob &jobFirst)
 Adds a dependency edge so this job runs after jobFirst.
 
void wait ()
 Waits for submitted work to complete.
 
void del ()
 Deletes scheduler resources and runs wrapper cleanup.
 

Detailed Description

Move-only wrapper for scheduler-owned ECS work.

SchedJob keeps the scheduler token together with the scheduler callbacks needed to submit, wait for, and delete the work. Query/system deferred execution uses this wrapper instead of exposing gaia::mt::JobHandle directly so external job systems can provide their own token type.

Constructor & Destructor Documentation

◆ SchedJob() [1/2]

gaia::ecs::SchedJob::SchedJob ( Sched  sched,
SchedToken  token,
bool  submitted,
void *  pCleanupCtx,
void(*)(void *pCtx)  cleanup 
)
inline

Creates a wrapper around token from sched.

Parameters
schedScheduler descriptor that created token.
tokenScheduler-owned work token.
submittedTrue if the scheduler already submitted token.
pCleanupCtxOptional cleanup context owned by the wrapper.
cleanupOptional cleanup callback executed after the job is waited or deleted unsubmitted.

◆ SchedJob() [2/2]

gaia::ecs::SchedJob::SchedJob ( SchedJob &&  other)
inlinenoexcept

Move-constructs a scheduler job wrapper.

Parameters
otherWrapper to move from.

Member Function Documentation

◆ dep()

void gaia::ecs::SchedJob::dep ( const SchedJob jobFirst)
inline

Adds a dependency edge so this job runs after jobFirst.

This member form mirrors the Gaia scheduler naming used by mt::ThreadPool::dep() and sched_dep(). It is equivalent to calling sched_dep() with jobFirst as the prerequisite and this job as the dependent work.

Parameters
jobFirstJob that must complete before this job can run.
Warning
Both jobs must use the same scheduler descriptor, and dependencies must be added before either job is submitted.
See also
sched_dep()
mt::ThreadPool::dep()

◆ operator=()

SchedJob & gaia::ecs::SchedJob::operator= ( SchedJob &&  other)
inlinenoexcept

Move-assigns a scheduler job wrapper.

Parameters
otherWrapper to move from.
Returns
Self reference.

◆ token()

GAIA_NODISCARD SchedToken gaia::ecs::SchedJob::token ( ) const
inline

Returns the opaque scheduler token.

Returns
Token owned by this wrapper.

◆ valid()

GAIA_NODISCARD bool gaia::ecs::SchedJob::valid ( ) const
inline

Returns true if this wrapper owns scheduler work.

Returns
True when a scheduler token is owned by the wrapper.

◆ wait()

void gaia::ecs::SchedJob::wait ( )
inline

Waits for submitted work to complete.

Warning
Waiting does not submit deferred work. Call submit() first.

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