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

maitake: add JoinHandle #184

Closed
hawkw opened this issue Jun 3, 2022 · 4 comments
Closed

maitake: add JoinHandle #184

hawkw opened this issue Jun 3, 2022 · 4 comments
Assignees
Labels
kind/enhancement New feature or request

Comments

@hawkw
Copy link
Owner

hawkw commented Jun 3, 2022

we should have that.

@hawkw
Copy link
Owner Author

hawkw commented Jun 3, 2022

essentially a JoinHandle is a wrapper type around a TaskRef that impls Future. in the simplest impl, you would have a WaitCell in the task struct for the join-interested task's waker, and if that's set when the task completes, you notify that task. the task vtable would add a function for moving the output out of the task cell, and the JoinHandle future would call that after it's woken.

eventually, we could use the existing state atomic for the join waker state instead of using a WaitCell that adds another word when it really just needs a couple bits. this would be more efficient, but WaitCell is probably good to start with.

@hawkw
Copy link
Owner Author

hawkw commented Jun 3, 2022

since TaskRefs are ref counted anyway, the JoinHandle would already keep the task alive while it exists (even after completion), and ensure it's deallocated on drop if the handle is the last ref.

@hawkw
Copy link
Owner Author

hawkw commented Jun 3, 2022

our JoinHandles don't have to worry about capturing a task panic like tokio/async-std's do, because maitake currently assumes panics are fatal (and neither of our operating systems support unwinding :P)

we might still want to return a Result if we want to add remote task aborts, though...

@hawkw
Copy link
Owner Author

hawkw commented Jun 3, 2022

@jamesmunns this could probably be pretty self-contained if you want something else to hack on...

@hawkw hawkw added the kind/enhancement New feature or request label Jun 3, 2022
hawkw added a commit that referenced this issue Jun 3, 2022
these increment/decrement the task's reference count and can drop the
task if the dropped `TaskRef` is the last ref.

Will be needed for #184

Depends on #188

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Jun 3, 2022
these increment/decrement the task's reference count and can drop the
task if the dropped `TaskRef` is the last ref.

Will be needed for #184

Depends on #188

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Jun 3, 2022
these increment/decrement the task's reference count and can drop the
task if the dropped `TaskRef` is the last ref.

Will be needed for #184

Depends on #188

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this issue Jun 3, 2022
these increment/decrement the task's reference count and can drop the
task if the dropped `TaskRef` is the last ref. this required some changes
to reference counting via poll state transitions.

will be needed for #184
depends on #188

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw closed this as completed in f744e6b Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants