3 releases

0.1.2 Jun 11, 2020
0.1.1 Jun 10, 2020
0.1.0 Jun 10, 2020

#1207 in Concurrency

MIT license

7KB
112 lines

scheduling

A very simple job scheduler. Runs one job (one-time or recurring) on one spawned thread.

Usage

fn main() {
    let _once_handle = scheduling::Scheduler::once(|| println!("ONCE")).start();

    let recurring_handle = scheduling::Scheduler::delayed_recurring(
        std::time::Duration::from_secs(1),
        std::time::Duration::from_secs(1),
        || println!("1 SEC ELAPSED"),
    )
    .start();

    std::thread::sleep(std::time::Duration::from_secs(5));

    recurring_handle.cancel();

    std::thread::sleep(std::time::Duration::from_secs(5));
}

License: MIT


lib.rs:

A very simple job scheduler. Runs one job (one-time or recurring) on one spawned thread.

Usage

fn main() {
let _once_handle = scheduling::Scheduler::once(|| println!("ONCE")).start();

let recurring_handle = scheduling::Scheduler::delayed_recurring(
std::time::Duration::from_secs(1),
std::time::Duration::from_secs(1),
|| println!("1 SEC ELAPSED"),
)
.start();

std::thread::sleep(std::time::Duration::from_secs(5));

recurring_handle.cancel();

std::thread::sleep(std::time::Duration::from_secs(5));
}

No runtime deps