clockctrl/lib.rs
1//! **A clock control mechanism for internally scheduled task
2//! runners**
3//!
4//! This library was primarily written as a utility for [Ratman], and
5//! libqaul, but can be used in any reactor setting where direct
6//! scheduling control should be possible without having to expose all
7//! tasks from it.
8//!
9//! [Ratman]: https://crates.io/crate/ratman
10//!
11//! ## Example: Ratman
12//!
13//! By default, each detached task inside Ratman is run at the speed
14//! that the hardware allows, i.e. polling tasks will not wait between
15//! poll loops. This is usually fine, on systems that are not battery
16//! or CPU constrained. However, on systems that are, it can cause
17//! huge battery drain. This is where [`ClockCtrl`] comes in, a clock
18//! receiver which can be configured with various types to manipulate
19//! the runtime behaviour of the internal tasks running inside Ratman.
20//!
21//! [`ClockCtrl`]: struct.ClockCtrl.html
22//!
23//! ```
24//! use clockctrl::{ClockCtrl, Error, Interval, Scheduler};
25//! use std::time::Duration;
26//!
27//! # #[derive(Hash, Eq, PartialEq, Ord, PartialOrd)] enum MyTasks { Journal, Switch }
28//! let mut clc = ClockCtrl::new();
29//! clc.setup(MyTasks::Journal)
30//! .set(Interval::Timed(Duration::from_secs(10)));
31//!
32//! clc.setup(MyTasks::Switch)
33//! .set(Interval::Stepped)
34//! .fence(move |_| {
35//! // ...
36//! });
37//! ```
38
39mod ctrl;
40pub use ctrl::{ClockCtrl, Scheduler};
41
42mod error;
43pub use error::Error;
44
45mod target;
46pub use target::{Target, Interval};