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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! # Momo
//!
//! A high-performance, atomic-free asynchronous runtime for Rust.
//!
//! **Momo** is an event-driven platform designed for writing non-blocking
//! asynchronous applications with strict **Thread-Local Affinity**. Unlike
//! traditional runtimes that rely on multi-threaded task migration, Momo
//! pins tasks to their creation threads, eliminating synchronization overhead
//! and core-to-core cache bouncing.
//!
//! ## Key Pillars
//!
//! - **[Execution Engine](crate::Executor)**: A localized task scheduler with zero-cost
//! cross-thread wakeups.
//! - **[Driver](crate::driver)**: A non-blocking I/O reactor supporting epoll,
//! kqueue, and IOCP.
//! - **[Time](crate::time)**: High-resolution timing via an O(1) hierarchical
//! timer wheel.
//! - **[Sync](crate::sync)**: Communication primitives optimized for
//! thread-local and cross-thread signaling.
//! - **[Net](crate::net)**: Unified async TCP and UDP networking.
//!
//! ## Getting Started
//!
//! Add **momo-rs** to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! momo-rs = "0.1"
//! ```
//!
//! ### A Simple Loop
//!
//! ```rust
//! use core::time::Duration;
//!
//! #[momo::main]
//! async fn main() {
//! momo::spawn(async {
//! println!("Hello from Momo!");
//! momo::time::sleep(Duration::from_millis(50)).await;
//! println!("Timer triggered on the local thread.");
//! });
//! }
//! ```
//!
//! ## The Fixed-Affinity model
//!
//! In Momo, every task is owned by the thread that spawned it.
//!
//! 1. **No `Send` Constraints**: You can safely spawn and run futures that
//! are `!Send`, as they are guaranteed never to migrate to another thread.
//! 2. **Deterministic Scheduling**: Local tasks are executed in a stable
//! FIFO order with a dedicated poll budget.
//! 3. **Local Memory Safety**: Share state between tasks on the same thread
//! with `Rc<RefCell<T>>` instead of heavier atomic primitives.
//!
//! ## Feature Flags
//!
//! Momo is modular. Configure your imports with these features:
//!
//! - `full`: All features enabled (default).
//! - `net`: Async TCP/UDP primitives.
//! - `sync`: Unbounded MPSC and Oneshot channels.
//! - `time`: Hierarchical timer support and sleeps.
//! - `macros`: The `#[momo::main]` entry point macro.
pub use ;
pub use momo_rs_driver as driver;
pub use momo_rs_time as time;
pub use momo_rs_net as net;
pub use momo_rs_sync as sync;
/// The common prelude for Momo.
pub use main;