Gears.jl

A Julia package for fine-grained scheduling

What is Gears.jl?

Gears.jl is a Julia package that brings precise timing control to simulation environments through fine-grained job scheduling. Whether you’re building real-time simulations, robotics systems, or event-driven applications, Gears provides the temporal precision you need with an elegant, intuitive API.

The package shines in its ability to handle multiple types of jobs simultaneously: timed jobs that execute at regular intervals, ASAP jobs that run as soon as possible, and event-driven jobs that respond to data arriving on channels. What makes Gears particularly powerful is its flexible time management system—you can work with machine time for real-world applications or controllable virtual time for simulations, all while supporting multi-threaded parallel execution. The scheduler intelligently manages job execution, ensuring that tasks run exactly when they should, whether that’s every 200 milliseconds or triggered by specific events.

using Gears

# Schedule a task every 200ms
every(200ms) do dt
    println("Task executed at $(now(global_clock()))")
end

# Run the scheduler for 1 second
for_next(1s) do
    update!()
end