Skip to main content

DomainWriteHandle

Struct DomainWriteHandle 

Source
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>
where D: Clone + Send + 'static,

Source

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:

  1. Awaits the first pending update (blocks).
  2. Drains all immediately-available updates (non-blocking).
  3. Sleeps for the coalesce_interval.
  4. Drains again for any stragglers.
  5. Clones the current data once, applies all closures, stores once.

The loop exits when all SharedDomainData senders are dropped.

Auto Trait Implementations§

§

impl<D> Freeze for DomainWriteHandle<D>

§

impl<D> !RefUnwindSafe for DomainWriteHandle<D>

§

impl<D> Send for DomainWriteHandle<D>
where D: Sync + Send,

§

impl<D> Sync for DomainWriteHandle<D>
where D: Sync + Send,

§

impl<D> Unpin for DomainWriteHandle<D>

§

impl<D> UnsafeUnpin for DomainWriteHandle<D>

§

impl<D> !UnwindSafe for DomainWriteHandle<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.