timerwheel 0.1.0

Hierarchical timer wheel for delayed task scheduling with pluggable executors.
Documentation
// 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.
pub mod error;
/// Executor traits and the default bounded worker pool.
pub mod executor;
/// Backpressure and rejection policies.
pub mod policy;
/// Common imports for applications that prefer a single glob import.
pub mod prelude;
/// Timer, timeout, builder, and timer metric types.
pub mod timer;

mod timing_wheel;

#[cfg(feature = "tokio")]
/// Tokio runtime adapters.
pub mod tokio;

pub use crate::error::{Error, Result};
pub use crate::policy::{BackpressurePolicy, ExpiredTaskPolicy, RejectPolicy};
pub use crate::timer::{Timeout, Timer, TimerBuilder, TimerMetrics};