Skip to content

How to advance the swarm state before entering the main eventloop #2041

Closed Answered by Frederik-Baetens
Frederik-Baetens asked this question in Q&A
Discussion options

You must be logged in to vote

This worked quite well for me:

    future::poll_fn(|cx| {
        if Swarm::listeners(&swarm).peekable().peek().is_some() {
            Poll::Ready(None)
        } else {
            Pin::new(&mut swarm).poll_next(cx)
        }
    }).await;

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mxinden
Comment options

@Frederik-Baetens
Comment options

Answer selected by Frederik-Baetens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants