Echo/Library.rs
1#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
2#![allow(
3 non_snake_case,
4 non_camel_case_types,
5 non_upper_case_globals,
6 dead_code,
7 unused_imports,
8 unused_variables,
9 unused_assignments
10)]
11
12//! # Echo: Work-Stealing Task Scheduler
13//!
14//! Echo keeps every CPU core busy. It uses a lock-free work-stealing queue
15//! (`crossbeam-deque`) so that idle threads automatically pick up tasks from
16//! busy ones. No central bottleneck, no wasted cores.
17//!
18//! ## Why Echo Instead of `tokio::spawn`
19//!
20//! Tokio is great for I/O-bound work, but CPU-bound tasks (parsing, diffing,
21//! indexing) block the executor. Echo provides:
22//!
23//! - **Priority levels**: UI-blocking tasks pre-empt background indexing
24//! - **Work stealing**: Idle workers take from busy workers' queues
25//! - **Structured shutdown**: Graceful drain with timeout
26//!
27//! ## Usage
28//!
29//! ```rust,ignore
30//! use Echo::Scheduler::SchedulerBuilder;
31//! use Echo::Task::Priority;
32//!
33//! let Scheduler = SchedulerBuilder::new().Workers(4).Build();
34//! Scheduler.Submit(Priority::High, async { /* critical work */ });
35//! Scheduler.Submit(Priority::Low, async { /* background indexing */ });
36//! ```
37//!
38//! ## Modules
39//!
40//! - [`Scheduler`]: Builder and runtime for the worker pool
41//! - [`Queue`]: Lock-free work-stealing deque wrapper
42//! - [`Task`]: Task definition with priority levels
43
44// --- Crate Modules ---
45// Declares the main modules that constitute the library.
46pub mod Queue;
47
48pub mod Scheduler;
49
50pub mod Task;