Expand description
Waking a blocked wait_events from another
thread.
A program whose work arrives off the loop thread — a D-Bus reply, a socket,
a timer thread, a finished download — needs the loop to notice it while the
loop is asleep in wait_events. A
ShellWaker is the handle that does it: cloned and sent to any thread,
where wake makes the current wait return, or the next
one return at once if none is running.
A wake carries nothing. It is a doorbell, not a message: the program
puts its data in its own channel and then rings, and the loop, once
wait_events has returned, drains that
channel. That keeps every backend’s mechanism the same size — a byte on a
pipe, a signalled event, one posted event — and no event type grows a
variant for data the shell never looks at.
Wakes coalesce. Any number of wakes between two waits end at most the next one or two of them early; none is ever lost, and none piles up. A loop that wakes, drains its channel and waits again therefore never misses work sent while it was draining.
Structs§
- Shell
Waker - Wakes one shell’s
wait_eventsfrom any thread — see the module docs.