-
I was just reading the documentation for tokio::JoinSet for the first time.
Can someone please explain this to me here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The pub trait Future {
type Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
} So when you manually implement the 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 |
Beta Was this translation helpful? Give feedback.
The
Future
trait is defined like this: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 atry_join_next
. (Similar to howmpsc::Receiver
hasrecv
,try_recv
, andpoll_recv
.)