Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JoinSet::poll_join_next a public API #5769

Closed
bartlomieju opened this issue Jun 6, 2023 · 2 comments
Closed

Make JoinSet::poll_join_next a public API #5769

bartlomieju opened this issue Jun 6, 2023 · 2 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-task Module: tokio/task

Comments

@bartlomieju
Copy link
Contributor

bartlomieju commented Jun 6, 2023

Is your feature request related to a problem? Please describe.
We're migrating deno_core to use JoinSet instead of FuturesUnordered based on suggestions from @Darksonn. deno_core has a main poll_event_loop function that responsible for polling all spawned tasks. With FuturesUnordered polling them was as simple as:

while let Poll::Ready(...) = state.pending_ops.poll_next_unpin(cx) {
  ...
}

however with JoinSet more ceremony (and pinning) is required:

loop {
  let item = {
    let next = std::pin::pin!(context_state.pending_ops.join_next());
    let Poll::Ready(Some(item)) = next.poll(cx) else {
      break;
    };
    item
  };
  ...
}

Describe the solution you'd like
Make JoinSet::poll_join_next API public, which would change the example above to:

while Poll::Ready(Some(item)) = context_state.pending_ops.poll_join_next(cx) {
  ...
};

Describe alternatives you've considered
Keep current API as is without changes.

@bartlomieju bartlomieju added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jun 6, 2023
@bartlomieju bartlomieju changed the title Add poll_join_next to JoinSet Make JoinSet::poll_join_next a public API Jun 6, 2023
@Darksonn Darksonn added the M-task Module: tokio/task label Jun 6, 2023
@Darksonn
Copy link
Contributor

Darksonn commented Jun 6, 2023

There's already a PR for this: #5721.

@bartlomieju
Copy link
Contributor Author

Thanks, I'm gonna close the issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-task Module: tokio/task
Projects
None yet
Development

No branches or pull requests

2 participants