-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Closed
Copy link
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateC-feature-requestCategory: A feature request.Category: A feature request.M-coopModule: tokio/coopModule: tokio/coop
Description
Is your feature request related to a problem? Please describe.
I'm trying to make a Stream that represents some resource participate in cooperative scheduling. From reading the Tokio source code I think this would boil down to a decorator that looks something like this.
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let coop = ready!(tokio::task::coop::poll_proceed(cx));
// do the actual Stream::poll_next
let ret = self.poll_next_internal(cx);
if ret.is_ready() {
coop.made_progress();
}
ret
}
poll_proceed is not accessible so this is currently not possible. I don't think I can achieve the same result using consume_budget
Describe the solution you'd like
Some mechanism to make an existing pollable item participate in cooperative scheduling.
Metadata
Metadata
Assignees
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateC-feature-requestCategory: A feature request.Category: A feature request.M-coopModule: tokio/coopModule: tokio/coop