1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Wall-clock-based timer utilities.
//!
//! This crate provides a timer that triggers actions at fixed wall-clock deadlines,
//! running on a dedicated thread. You interact with the timer through a cloneable
//! handle (`TimerRef`) and schedule actions by absolute `SystemTime` deadlines.
//!
//! # Quick start (UUID ids)
//! ```no_run
//! use wallclock_timer::thread_timer::UuidClosureTimer;
//! use wallclock_timer::ClosureTimer;
//! use std::time::{Duration, SystemTime};
//! use uuid::Uuid;
//!
//! let timer = UuidClosureTimer::default();
//! let mut tref = timer.timer_ref();
//!
//! let deadline = SystemTime::now() + Duration::from_secs(1);
//! tref.schedule_action_at(Uuid::new_v4(), deadline, |id| {
//! println!("Triggered {id}");
//! }).expect("schedule");
//!
//! std::thread::sleep(Duration::from_secs(2));
//! timer.shutdown().expect("shutdown");
//! ```
//!
//! # Errors and logging
//! Public APIs return an implementation-specific [[Result]]
//! (e.g. [[thread_timer::ThreadTimerError]] for the [[thread_timer::TimerWithThread]])
//! for failures (such as channel send errors).
//!
//! The crate also uses the `log` facade for internal error reporting. Provide a logger
//! implementation in your application to see logs.
//!
//! # UUID feature
//! Enable the `uuid` feature to use UUID ids and the UUID-based shorthand aliases:
//! - [[thread_timer::UuidClosureTimer]]
//! - [[thread_timer::UuidClosureTimerRef]]
//!
//! # Chrono feature
//! Enable the `chrono` feature to schedule timers using `chrono::DateTime` via
//! [[timers::chrono::ChronoTimer::schedule_at_datetime]].
pub use *;