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

Update documentation for Once to reference std::sync::OnceLock. #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

briansmith
Copy link

No description provided.

/// Unlike its `std::sync` equivalent, this is generalized such that the closure returns a
/// value to be stored by the [`Once`] (`std::sync::Once` can be trivially emulated with
/// `Once`).
/// This is analogous to `std::sync::OnceLock`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I think this is probably too strong a statement. They're definitely very similar, but the APIs differ enough that I'd probably go for something like:

This type has similar behaviour to `std::sync::OnceLock`.

Copy link
Author

Choose a reason for hiding this comment

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

The previous "equivalent" was already much stronger language than "analogous," which isn't any stronger of a statement than "similar behavio[u]r." For most people, if they need a spinlock variant of std::sync::OnceLock then they'll consider spin::Once.

Comment on lines -42 to -43
//! - [`Once`] owns the value returned by its `call_once` initializer.
//!
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason for removing this?

Copy link
Author

Choose a reason for hiding this comment

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

Previously, we were comparing spin::Once to std::sync::Once, which didn't own the result of the initializer. Now we're comparing it to OnceLock, which does own the result of the initializer.

@zesterer
Copy link
Collaborator

zesterer commented Dec 9, 2023

Apologies for not finishing off this review earlier, I've had a lot on this week. I should be in a position to finish this off tomorrow.

@tgross35
Copy link

The same updates could probably be applied to spin::Lazy now that std::sync::LazyLock is now stable.

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.

3 participants