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
//! # giong
//!
//! A thread-per-core async runtime for Linux, built directly on **io_uring**.
//!
//! Named after Thánh Gióng, the child of Vietnamese legend who lay silent for
//! three years and then rose a giant: giong costs next to nothing while idle
//! and uses every core the moment load arrives.
//!
//! ## Design
//!
//! * **Thread-per-core, shared-nothing.** Every worker thread owns its own
//! io_uring, task queue, timers and buffer pool. Tasks never migrate, so
//! futures need not be `Send` and the hot path has no locks and no atomics
//! beyond a waker flag.
//! * **Completion-based I/O with batching.** Everything a tick produces —
//! reads, writes, accepts, closes, cancellations — reaches the kernel in a
//! single `io_uring_enter`, which also returns every completion that is
//! ready.
//! * **Multishot accept and receive** with kernel-provided buffers: one
//! submission per listener / connection, no buffer pinned by idle
//! connections.
//! * **One ring for everything.** TCP, UDP and Unix sockets ([`net`]) and
//! files ([`fs`]) all go through the worker's io_uring. File I/O needs no
//! pool of blocking threads.
//! * **A latency dial.** [`Builder::spin_before_park`] lets a worker watch its
//! ring instead of sleeping, for services where microseconds matter more
//! than an idle core.
//! * **Cancellation safety.** Dropping an I/O future never frees memory the
//! kernel may still write to; ownership of the buffer moves to the driver
//! until the kernel confirms.
//!
//! ## Example
//!
//! ```no_run
//! use giong::net::TcpListener;
//!
//! fn main() -> std::io::Result<()> {
//! giong::Builder::new().shutdown_on_signals(true).build()?.run(|_worker| async {
//! let listener = TcpListener::bind("0.0.0.0:8080").expect("bind");
//! while let Some(Ok(stream)) = giong::until_shutdown(listener.accept()).await {
//! giong::spawn(async move {
//! loop {
//! let Ok(data) = stream.recv().await else { return };
//! if data.is_empty() {
//! return; // peer closed
//! }
//! let reply = data.to_vec();
//! drop(data); // give the buffer back to the pool
//! if stream.write_all(reply).await.0.is_err() {
//! return;
//! }
//! }
//! });
//! }
//! })
//! }
//! ```
//!
//! ## Requirements
//!
//! Linux 6.0 or newer (6.1+ recommended). giong does not build on other
//! platforms.
compile_error!;
pub use ;
pub use ;
pub use ;
pub use ;