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

Add a task set #3908

Closed
wants to merge 3 commits into from
Closed

Add a task set #3908

wants to merge 3 commits into from

Conversation

MikailBag
Copy link
Contributor

Motivation

Closes #3903

Solution

I selected a straightforward approach for the first version. However, try_poll_next_finished implementation should be definitely optimized for a large amounr of tasks, because currently, TaskSet is effectively quadratic.

Also, I wonder if moving spawn method to a clone-able TaskSetSpawner type makes more sense.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Jun 30, 2021
@Darksonn
Copy link
Contributor

We are going to want an implementation that is not quadratic. Also, the mutex is unnecessary.

@Darksonn
Copy link
Contributor

And I don't think we want a TaskSetSpawner, but that is a discussion for the issue.

@MikailBag
Copy link
Contributor Author

MikailBag commented Jun 30, 2021

We are going to want an implementation that is not quadratic

Ok, I'm going to write one.

I have the following in mind (I think it is similar to FuturesUnordered):

  1. Handles are stored in a linked list on the top of Vec, and we separately keep track of holes.
  2. Spawning is straightforward.
  3. Polling os more complex. For each task we create a custom waker which knows the id of the task (i.e. position in vector). When woken, waker stores this id in a wake queue. Task is also placed into wake queue just after it is spawned

I think this will achieve desired linear run time. Does it sound fine?

@Darksonn
Copy link
Contributor

In general it is dangerous to start working on a PR before we have finished discussing the design. You risk wasting your time on something that doesn't end up being the implementation we end up wanting.

@Darksonn
Copy link
Contributor

Darksonn commented Feb 8, 2022

Closing since this was implemented in #4335 instead.

@Darksonn Darksonn closed this Feb 8, 2022
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 M-task Module: tokio/task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a TaskSet
2 participants