Expand description
§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: A localized task scheduler with zero-cost cross-thread wakeups.
- Driver: A non-blocking I/O reactor supporting epoll, kqueue, and IOCP.
- Time: High-resolution timing via an O(1) hierarchical timer wheel.
- Sync: Communication primitives optimized for thread-local and cross-thread signaling.
- Net: Unified async TCP and UDP networking.
§Getting Started
Add momo-rs to your Cargo.toml:
[dependencies]
momo-rs = "0.1"§A Simple Loop
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.
- No
SendConstraints: You can safely spawn and run futures that are!Send, as they are guaranteed never to migrate to another thread. - Deterministic Scheduling: Local tasks are executed in a stable FIFO order with a dedicated poll budget.
- 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.
Modules§
- driver
- Momo (I/O Reactor Driver)
- net
- Momo (Asynchronous Networking)
- prelude
- The common prelude for Momo.
- sync
- Momo (Synchronization & Communication)
- time
- Momo (Time & Timers)
Structs§
- Executor
- A handle to the core task scheduler for momo-rs.
Functions§
- has_
pending_ tasks - Internal check for whether any tasks are ready to be polled.
- is_
stopped - Returns whether the runtime has been signaled to stop.
- set_
wakeup_ handler - Internal registration for cross-thread reactor wakeups.
- spawn
- Spawns a new asynchronous task into the momo-rs engine.
- stop
- Signals the
momo-rsruntime to stop execution on the current thread. - yield_
now - Cooperatively yields control back to the momo-rs scheduler.