clockctrl 0.1.0

An asynchronous framework to provide various clock stepping for reactors
Documentation
  • Coverage
  • 100%
    20 out of 20 items documented1 out of 1 items with examples
  • Size
  • Source code size: 26.98 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.51 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • spacekookie

A clock control mechanism for internally scheduled task runners

This library was primarily written as a utility for Ratman, and libqaul, but can be used in any reactor setting where direct scheduling control should be possible without having to expose all tasks from it.

Example: Ratman

By default, each detached task inside Ratman is run at the speed that the hardware allows, i.e. polling tasks will not wait between poll loops. This is usually fine, on systems that are not battery or CPU constrained. However, on systems that are, it can cause huge battery drain. This is where ClockCtrl comes in, a clock receiver which can be configured with various types to manipulate the runtime behaviour of the internal tasks running inside Ratman.

use clockctrl::{ClockCtrl, Error, Interval, Scheduler};
use std::time::Duration;

# #[derive(Hash, Eq, PartialEq, Ord, PartialOrd)] enum MyTasks { Journal, Switch }
let mut clc = ClockCtrl::new();
clc.setup(MyTasks::Journal)
    .set(Interval::Timed(Duration::from_secs(10)));

clc.setup(MyTasks::Switch)
    .set(Interval::Stepped)
    .fence(move |_| {
        // ...
    });