Why poll-based futures in Rust

Reference: https://www.reddit.com/r/rust/comments/92th5t/why_is_futuresrs_poll_mechanism_better_than_event/

Why?

Rust has a Future trait which allows users to create libraries with different asynchronous runtimes.

To implement Future, you have to define a poll method.

The naive thing to do would just be to poll the future until you are successful.

That makes it seem really inefficient however, it clogs up CPU time while busy waiting.

However, that is a misconception.

How to use it properly

Future should notify subfutures on events occurring, rather than polling based approach.

Design

Futures are designed to be composable. So the above pattern repeats.

The top-level future will watch for all events any sub-future is interested in, and delegate to sub future as needed.