moonpool_sim/sim/wakers.rs
1//! Waker management for async coordination.
2//!
3//! This module provides the `WakerRegistry` for managing task wakers
4//! in the simulation environment.
5
6use std::collections::BTreeMap;
7use std::task::Waker;
8
9use crate::network::sim::{ConnectionId, ListenerId};
10use crate::sim::state::FileId;
11
12/// Waker management for async coordination.
13#[derive(Debug, Default)]
14pub struct WakerRegistry {
15 /// Wakers waiting on `accept()` per listener.
16 pub(crate) listeners: BTreeMap<ListenerId, Waker>,
17 /// Wakers waiting on `read` per connection.
18 pub(crate) reads: BTreeMap<ConnectionId, Waker>,
19 /// Wakers waiting on time-based events per task id.
20 pub(crate) tasks: BTreeMap<u64, Waker>,
21 /// Wakers waiting for write clog to clear.
22 pub(crate) write_clogs: BTreeMap<ConnectionId, Vec<Waker>>,
23 /// Wakers waiting for read clog to clear.
24 pub(crate) read_clogs: BTreeMap<ConnectionId, Vec<Waker>>,
25 /// Wakers waiting for cut connections to be restored.
26 pub(crate) cuts: BTreeMap<ConnectionId, Vec<Waker>>,
27 /// Wakers waiting for send buffer space to become available.
28 pub(crate) send_buffers: BTreeMap<ConnectionId, Vec<Waker>>,
29 /// Wakers waiting for storage operations to complete.
30 /// Keyed by (`FileId`, `operation_sequence_number`).
31 pub(crate) storage_ops: BTreeMap<(FileId, u64), Waker>,
32}