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

task: Add TaskLocalFuture::take_value method to the task_local #9

Closed
wants to merge 2 commits into from

Conversation

mox692
Copy link
Owner

@mox692 mox692 commented Feb 11, 2024

Motivation

Try to resolve #.
This PR adds a method take_value to take the task local value of a TaskLocalFuture.
The LocalKey::scope function owns the slot value and drops it, but this method will allow you to re-acquire ownership of the slot value.

Solution

Implemented method take_value for a pinned TaskLocalFuture.
Maybe it is possible to provide non-pinned api as well (pub fn take_value(&mut self) -> Option<T>), but I'm not sure if it is worth providing both.

@mox692 mox692 force-pushed the task_local_future_take_value_exp branch 6 times, most recently from 1438843 to 22ec162 Compare February 12, 2024 14:41
@mox692 mox692 changed the title add take_value task: Add TaskLocalFuture::take_value method to the task_local Feb 12, 2024
@mox692 mox692 closed this Feb 14, 2024
@mox692 mox692 reopened this Feb 15, 2024
@mox692 mox692 force-pushed the task_local_future_take_value_exp branch from 22ec162 to f1e7edd Compare February 15, 2024 14:51
@mox692 mox692 closed this Feb 22, 2024
@mox692 mox692 deleted the task_local_future_take_value_exp branch April 13, 2024 06:35
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.

1 participant