1 unstable release
0.1.0 | Jan 30, 2020 |
---|
#25 in #reactor
11KB
125 lines
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;
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 |_| {
// ...
});
Dependencies
~4–13MB
~167K SLoC