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

Simplify using lock_arc #20

Merged
merged 1 commit into from Jan 28, 2022
Merged

Simplify using lock_arc #20

merged 1 commit into from Jan 28, 2022

Conversation

espindola
Copy link
Contributor

The future returned by lock_arc would already resolve to a
MutexGuardArc that kept the Arc alive. Unfortunately, sometimes
one needs to store the future itself, not the MutexGuardArc and the
future had a reference to the Arc.

With this patch, the future itself also has a Arc.

The future returned by lock_arc would already resolve to a
MutexGuardArc that kept the Arc<Mutex> alive. Unfortunately, sometimes
one needs to store the future itself, not the MutexGuardArc and the
future had a reference to the Arc<Mutex>.

With this patch, the future itself also has a Arc<Mutex>.
@espindola
Copy link
Contributor Author

For comparison, tokio's mutex has the api:

pub async fn lock_owned(self: Arc<Self>) -> OwnedMutexGuard<T>

note that it takes self by value.

Copy link
Collaborator

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@taiki-e taiki-e merged commit 1b63cc6 into smol-rs:master Jan 28, 2022
@taiki-e
Copy link
Collaborator

taiki-e commented Feb 19, 2022

Published in 2.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants