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

Remove MaybeDone from impl Join for Vec #29

Merged
merged 2 commits into from
Nov 7, 2022

Conversation

yoshuawuyts
Copy link
Owner

This is the first step towards #22. Conceptually it moves us from the existing structure, which has all things together in a single enum:

pub struct Join<Fut: Future> {
    state: Pin<Vec<MaybeDone<Fut>>>>,
}

Towards a separated input/output/metadata structure, which has far better locality:

pub struct Join<Fut: Future> {
    #[pin]
    futures: Vec<Fut>,
    items: Vec<MaybeUninit<<Fut as Future>::Output>>,
    metadata: Vec<Metadata>,
}

This requires some unsafe at the end to transmute the MaybeUninit<T> to T. Which also requires us to mess around with custom drop implementations. But as a result, it should have better locality since we only ever have to write the data once.


Because this is the first iteration of a series of PRs, it has a lot more things going on. We introduce a new type: Metadata, which tracks the state. Unlike MaybeDone which wraps a T, Metadata is expected to be co-located with the state. Each piece of Metadata carries an enum State, which tracks what state the futures and output are in.


r? @eholk, this ties into some of the earlier work we've been doing. Tagging you so you can take a look if you're interested!

src/future/join/vec.rs Outdated Show resolved Hide resolved
src/future/join/vec.rs Show resolved Hide resolved
src/future/join/vec.rs Outdated Show resolved Hide resolved
src/future/join/vec.rs Outdated Show resolved Hide resolved
src/utils/metadata.rs Outdated Show resolved Hide resolved
src/utils/metadata.rs Outdated Show resolved Hide resolved
src/utils/pin.rs Show resolved Hide resolved
@yoshuawuyts yoshuawuyts merged commit 1b422ee into main Nov 7, 2022
@delete-merged-branch delete-merged-branch bot deleted the remove-maybe-done-vec-join branch November 7, 2022 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants