Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Async Gate

The async gate is backed by tokio::sync::Notify and is intended for Tokio task fanout and stream pipelines.

#![allow(unused)]
fn main() {
use memory_admission::r#async::AdmissionGate;

let gate = AdmissionGate::new_default();
let permit = gate.acquire().await;

// Do memory-sensitive async work.

drop(permit);
}

Hold the permit for the lifetime of the operation that contributes to memory pressure.