pub struct Waiters { /* private fields */ }Expand description
Every parked client, oldest first.
The order is the order they blocked in and it is the order they are served
in, which is what makes a queue with several workers on it fair: two clients
blocked on the same key take the two elements a RPUSH q first second adds
in the order they arrived. A Vec is the right structure for that while the
list is short, and it is short, because a waiter is a client doing nothing.
Implementations§
Source§impl Waiters
impl Waiters
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many clients are parked, which is what INFO clients calls
blocked_clients.
Sourcepub fn at(&self, at: usize) -> Parked
pub fn at(&self, at: usize) -> Parked
Where the waiter at at has to be answered.
§Panics
If at is past the end, which only a caller that ignored Waiters::len
can manage.
Sourcepub fn forget(&mut self, client: u64)
pub fn forget(&mut self, client: u64)
Take off every waiter belonging to a client that has gone.
Called when a connection closes rather than left for the deadline sweep
to find, because a BLPOP key 0 on a connection nobody will ever write
to again has no deadline to be found by.
Sourcepub fn bind(&mut self, client: u64, conn: u32)
pub fn bind(&mut self, client: u64, conn: u32)
Say which slot the waiter this client just registered is answered on.
The command layer knows which client blocked and the engine knows which slot that client is on, so the slot is filled in afterwards by the half that has it. A client can only be parked once, since it is not reading commands while it waits, so the search finds the one that was just added.