Jobs

Overview

Jobs represent the actual work to be performed in Gears. There are three types of jobs, each with different execution characteristics.

Job Interface

All jobs implement the Job abstract type and must provide:

progress!(job::Job, t::Quantity{<:Number, 𝐓})
Gears.progress!Function
progress!(ticker::Ticker, delta_time::Quantity{<:Number, 𝐓})

Progress the ticker by a delta time, updating internal state accordingly.

source
progress!(job::Job, t::Quantity{<:Number, 𝐓})

Execute the job with the current time. The job decides internally whether to perform work.

source
progress!(job::TimedJob, dt::Quantity{<:Number, 𝐓})

Progress the job by the specified time delta, executing the function for each available tick.

source

Job Types

TimedJob

Execute at regular intervals. Created with every(scheduler, interval).

AsapJob

Execute as soon as possible (highest priority). Created with every(scheduler, asap).

EventJob

Execute when data arrives on a channel. Created with every(scheduler, channel).

Usage Examples

# Timed job - executes every 10ms
every(scheduler, 10ms) do dt
    plan!(agent)
end

# ASAP job - executes as soon as possible
every(scheduler, asap) do
    process_urgent_task()
end

# Event job - executes when data arrives
events = Channel{String}(Inf)
every(scheduler, events) do event
    handle_event(event)
end