tokio-rs / doc-push

Tokio doc blitz effort - A concerted effort to improve Tokio's documentation.
MIT License
50 stars 7 forks source link

what should I pay attention to when implmenting poll? #58

Open shaitao opened 6 years ago

shaitao commented 6 years ago

It's confusing to implement poll, when and where to use NotReady

carllerche commented 6 years ago

Thanks for the feedback.

Do you have specific examples where you got tripped up? What were you trying to implement? What did your first attempt look like?

jonhoo commented 6 years ago

I completely agree that a write-up of "how you likely want to implement and think about poll" is likely a good addition.

carllerche commented 6 years ago

@jonhoo What would you say should go in that section?

shaitao commented 6 years ago

Thanks for the feedback.

Do you have specific examples where you got tripped up? What were you trying to implement? What did your first attempt look like? It looks like that if the poll of a source future block and all the futures will block. if I implement

fn poll(&self)->Poll<T,E>{
let x = loading()? //this is not a future and would block
Ok(Async::Ready(x))  //how to return NotReady
}
jonhoo commented 6 years ago

@carllerche