pub async fn race_command_with_publication<C, F, R>(
sender: Arc<RwLock<UnboundedSender<C>>>,
connect: F,
command: impl FnOnce() -> C + Send + 'static,
active: impl Fn() -> bool,
) -> RExpand description
Connects while injecting a command immediately after the shared sender becomes available.
command constructs the command after acquiring the newly published sender.
The sender must use Tokio’s fair read/write lock. This function holds a reader until
connect queues its publication writer, then queues the command’s reader behind it.
The reader’s waker sends the command synchronously during publication, before connect
can continue past releasing the writer. No scheduler timing or sleep is required.
§Panics
Panics if connection or publication takes more than five seconds, connect finishes before
publication, active is true before publication, or the command cannot enter the new channel.