Is it valid to poll a future before it's being woken?

The doc of Future::poll says:

The poll function is not called repeatedly in a tight loop – instead, it should only be called when the future indicates that it is ready to make progress (by calling wake() ).

Does that mean async runtimes must not poll a future before it's being woken and in case this rule is violated the future can simply panic?

No, it just means it's a bad idea to hot loop over poll.

Futures can and will be polled when not woken. For example, the future returned by join doesn't track which of its inner futures was woken, so it always polls both.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.