tor-proto: consolidate `Channel`s "closed" state handling
Previously Channel
had two concepts of "closed". There was an atomic flag that was set to true
at the end Reactor::run
, and an experimental oneshot channel where the sender was dropped when the reactor was dropped.
This MR consolidates these two using a new oneshot_broadcast
module, which combines a This means that the behaviour is consistent between both "closed" statuses (AtomicBool
with oneshot::{Receiver,Sender}
and futures::Shared
. (This could be done nicer with a completely custom channel type, but it feels overboard unless we need it.)is_closing()
and wait_for_close()
). A channel is considered closed when its reactor is dropped.
Edit: The oneshot_broadcast
module was rewritten in later commits to use a OnceLock
and Mutex
instead.
This also helps progress towards making the channel reactor cancellation safe (see #1756).
My goal is to later make Channel::wait_for_close
non-experimental so that I can use it in the channel manager to detect when the channel closes. Before doing this, I wanted to ensure that both Channel::is_closing
and Channel::wait_for_close
were consistent.