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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright © 2026-present The Timerwheel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Delayed task scheduling with a hierarchical timer wheel.
//!
//! The default timer uses standard library threads and synchronization
//! primitives. Expired tasks are dispatched to an executor so task execution
//! does not block scheduler progress.
//! The scheduler advances time and dispatches expired tasks through
//! [`executor::Executor::try_execute`]. The default pool and optional runtime
//! adapters keep worker execution outside the scheduler thread. Custom
//! executors must return from `try_execute` immediately and return the original
//! task in [`executor::RejectedTask`] when they cannot accept work.
//!
//! # Example
//!
//! ```
//! use std::sync::mpsc;
//! use std::time::Duration;
//!
//! use timerwheel::Timer;
//!
//! let timer = Timer::builder()
//! .tick(Duration::from_millis(1))
//! .bucket_count(64)
//! .build()?;
//! let (tx, rx) = mpsc::channel();
//!
//! let timeout = timer.schedule(Duration::from_millis(5), move || {
//! tx.send("fired").expect("send succeeds");
//! })?;
//!
//! assert_eq!(rx.recv_timeout(Duration::from_secs(1))?, "fired");
//! let _ = timeout;
//! timer.shutdown()?;
//!
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
/// Error and result types returned by timerwheel APIs.
/// Executor traits and the default bounded worker pool.
/// Backpressure and rejection policies.
/// Common imports for applications that prefer a single glob import.
/// Timer, timeout, builder, and timer metric types.
/// Tokio runtime adapters.
pub use crate;
pub use crate;
pub use crate;