pub struct DomainWriteHandle<D> { /* private fields */ }Expand description
Handle to the write side of a SharedDomainData double buffer.
Returned by SharedDomainData::new or SharedDomainData::with_coalesce.
Must be spawned as a tokio task via run at startup
to process pending updates.
The write task exits automatically when all SharedDomainData clones are
dropped (the underlying channel closes).
§Batching
Updates are coalesced into batches to minimize cloning and ArcSwap store
operations. After the first update arrives, the task drains any
immediately-available updates, waits for the configured coalesce interval,
drains again, then applies the entire batch in a single clone → apply → store
cycle.
Implementations§
Source§impl<D> DomainWriteHandle<D>
impl<D> DomainWriteHandle<D>
Sourcepub async fn run(self)
pub async fn run(self)
Run the write loop until the channel closes.
Spawn this as a tokio task: tokio::spawn(write_handle.run()).
Each iteration:
- Awaits the first pending update (blocks).
- Drains all immediately-available updates (non-blocking).
- Sleeps for the
coalesce_interval. - Drains again for any stragglers.
- Clones the current data once, applies all closures, stores once.
The loop exits when all SharedDomainData senders are dropped.