background-runner

Crates.iobackground-runner
lib.rsbackground-runner
version0.1.2
created_at2025-09-05 21:06:03.576787+00
updated_at2025-09-07 18:28:22.211692+00
descriptionRun a heavy task in the background multiple times without blocking the triggering thread
homepage
repositoryhttps://codeberg.org/CoffeJunkStudio/background-runner
max_upload_size
id1826205
size25,362
(Cryptjar)

documentation

README

Background Runner

The purpose of this crate is to run a heavy task in the background multiple times without blocking the triggering thread. The motivating use case is to periodically write to a file from a game loop.

// Create a background runner and give it a task to run
let runner = BackgroundRunner::new(move |state| {
    // Heavy work goes here
});

// Some state to repeatedly pass to the runner.
// This can be anything that's Send + 'static
let state = 42;
loop {
    // Light work goes here

    // Trigger the runner if it's not busy currently
    runner.update(&state);
}

The update() method is guaranteed to never block the calling thread. It will only trigger the runner's task if it's not currently running (i.e. busy with processing a previous run request).

Commit count: 0

cargo fmt