Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
JobHandle Class Reference

Lightweight handle returned when a job is submitted to JobSystem. More...

#include <JobSystem.h>

Public Member Functions

bool valid () const
 Returns true if this handle refers to a submitted job.
bool isDone () const
 Returns true once the job reaches Completed, Canceled, or Failed.
bool isRunning () const
 Returns true while the job function is currently executing.
bool isCancelRequested () const
 Returns true if cooperative cancellation has been requested.
JobStatus status () const
 Returns the current job status, or JobStatus::Canceled for an invalid handle.
std::exception_ptr exception () const
 Returns the exception captured from the job function, if status() is JobStatus::Failed.
bool requestCancel () const
 Request cooperative cancellation.
void wait () const
 Block until the job reaches Completed, Canceled, or Failed.
bool waitFor (std::chrono::milliseconds timeout) const
 Block until the job reaches a terminal state or until the timeout expires.

Detailed Description

Lightweight handle returned when a job is submitted to JobSystem.

JobHandle is a shared, copyable view of a job's completion state. It can be ignored for fire-and-forget work, or kept by native code that needs to wait for completion, poll status, or request cooperative cancellation.

Note
Cancellation is cooperative. A queued job may be skipped, but a running job must check the cancellation state and return by itself.
Warning
Avoid calling wait() from a JobSystem worker thread when the waited job may be queued behind the current worker. The current executor does not steal queued work while waiting.
This is a native C++ synchronization object. It is not intended to be exposed directly to scripting bindings.

Member Function Documentation

◆ requestCancel()

bool requestCancel ( ) const

Request cooperative cancellation.

If the job is still queued, it is marked Canceled and will not execute. If it is already running, the job function must observe cancellation through its own captured state or through this handle and return voluntarily.

Returns
false if the handle is invalid, otherwise true.

The documentation for this class was generated from the following file:
  • JobSystem.h