pub struct Expected(/* private fields */);Expand description
The list the gate is enforcing right now.
A SIGHUP replaces it, so the handle is shared rather than copied: the
socket wrapper is built once at bind time and has to see a reload without
being rebuilt, since rebuilding it would mean rebinding the port.
Read once per receive batch rather than once per datagram, and written once
per reload, so a plain RwLock around an Arc is all the sharing this needs.
The flag beside it answers “is there a list at all” without taking the lock,
because an empty list is the shipped default and every release before v0.9.0
behaved that way. A gate that is off then costs a receive batch one atomic
load rather than a read guard, an Arc clone and its drop.
Implementations§
Source§impl Expected
impl Expected
Sourcepub fn set(&self, names: Names)
pub fn set(&self, names: Names)
Replaces the list, for every datagram received from now on.
The list is written first and the flag second, with a Release store
against the Acquire load in Expected::any, so a reader that sees
the flag set also sees the list the flag is about.
The order matters in one direction only. A reader that has already loaded the flag while it still said “empty” judges its batch against the list that was in force a moment earlier, which is what a reload means for every datagram that arrived just before it and is why the gate can be reloaded at all. Storing the flag first would allow the opposite: a reader seeing “there is a list” and then reading a list that is not yet the new one, which is a judgement made against a list no configuration ever asked for.