pub(crate) struct ShapeControl {
profile: Mutex<Option<ShapeProfile>>,
generation: AtomicU64,
enabled: Arc<AtomicBool>,
}Expand description
This proxy’s shaping profile, and whether it paces.
One per proxy, watched by every session it accepts. The generation is what lets a session notice a change without comparing profiles: a session caches the generation its scheduler was built at, and a mismatch is the signal to look.
Fields§
§profile: Mutex<Option<ShapeProfile>>The profile a live request installed, or None while the proxy’s own
template is what every session shapes with.
generation: AtomicU64Bumped, under the lock above, every time the profile is replaced.
enabled: Arc<AtomicBool>Whether the schedulers built from this pace at all. Behind its own
Arc because every scheduler holds a clone of it.
Implementations§
Source§impl ShapeControl
impl ShapeControl
Sourcefn new() -> Self
fn new() -> Self
A control with no profile of its own and pacing switched on, which is the state that leaves a proxy behaving exactly as its configuration says.
Sourcefn set(&self, profile: ShapeProfile)
fn set(&self, profile: ShapeProfile)
Replace the profile and move the generation on.
Sourcepub(crate) fn generation(&self) -> u64
pub(crate) fn generation(&self) -> u64
The current generation, without cloning a profile.
What a session checks per stream; the clone below is paid only when this has moved.
Sourcepub(crate) fn snapshot(&self) -> (u64, Option<ShapeProfile>)
pub(crate) fn snapshot(&self) -> (u64, Option<ShapeProfile>)
The generation and the profile it names, read together.
Read under the lock the setter writes under, so the pair cannot
straddle two calls to Self::set — a session that cached a
generation from one profile and a profile from another would stop
noticing the newer of the two.
Sourcepub(crate) fn switch(&self) -> Arc<AtomicBool> ⓘ
pub(crate) fn switch(&self) -> Arc<AtomicBool> ⓘ
The switch every scheduler built from this reads.
Sourcefn set_enabled(&self, on: bool)
fn set_enabled(&self, on: bool)
Turn pacing on or off for every session at once.