CapGdlrJobs.JobSpecΒΆ

Inherits: RefCounted < Object

Describes one job.

DescriptionΒΆ

Extend it, declare a KEY constant, and override _run():

class_name LoadSaveJob
extends CapGdlrJobs.JobSpec

const KEY := &"save/load"

func _ensure_requirements() -> GdbPromise:
    return ensure_job(MountStorageJob.KEY)

func _run(args := {}) -> GdbPromise:
    return GdbPromise.new_resolved(load_save())

Register the specification with CapGdlrJobsRegistry.register_job().

MethodsΒΆ


Method DescriptionsΒΆ

StringName get_key() πŸ”—

Returns the KEY constant of the specification.


void initialize(svc_jobs: CapGdlrJobs) πŸ”—

Connects the specification to the jobs service. The service calls it before the job starts.


GdbPromise ensure_requirements() πŸ”—

Returns a promise that resolves when the requirements are met. See _ensure_requirements().


GdbPromise run(args: Dictionary = {}) πŸ”—

Runs the job. See _run().


void abort_current_run() πŸ”—

Stops the current run. CapGdlrJobs.reset_job() calls it when it aborts the job. Override it to cancel work. The default does nothing.


Variant get_job_output(key: StringName) πŸ”—

Returns the output of another job. See CapGdlrJobs.get_job_output().


JobStatus get_job_status(key: StringName) πŸ”—

Returns the status of another job. See CapGdlrJobs.get_job_status().


GdbPromise ensure_job(key: StringName) πŸ”—

Returns a promise of the output of another job. See CapGdlrJobs.ensure_job(). Use it in _ensure_requirements().


JobRunPolicy get_run_policy() πŸ”—

Returns the run policy. See _get_run_policy().


GdbPromise _run(args: Dictionary = {}) πŸ”—

Override it to do the work. Return a promise of the job output. Reject the promise to fail the job.


GdbPromise _ensure_requirements() πŸ”—

Override it to wait for other jobs or resources before _run(). The default resolves at once.


JobRunPolicy _get_run_policy() πŸ”—

Override it to change when the job starts. The default is CapGdlrJobs.WHEN_REQUIRED.