Skip to content

What is the Context that is used by JoinSet::poll_join_next()? #6157

Answered by Darksonn
DanielT asked this question in Q&A
Discussion options

You must be logged in to vote

The Future trait is defined like this:

pub trait Future {
    type Output;
    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
}

documentation

So when you manually implement the Future trait, the context is available to you. It's not available when using the async/await syntax.

If all you want is a way try to get the next future if one is immediately available, then you shouldn't use the poll methods. Instead, use now_or_never on the non-poll method. You may also want to file a feature request for a try_join_next. (Similar to how mpsc::Receiver has recv, try_recv, and poll_recv.)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DanielT
Comment options

Answer selected by DanielT
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