Skip to content

Conversation

dignifiedquire
Copy link

No description provided.

@indiv0
Copy link
Owner

indiv0 commented Jun 22, 2019

Thanks! Feel free to add yourself to the CONTRIBUTORS.md with this PR if you'd like.

/// This function will return `Some` if the cell has been previously
/// initialized, and `None` if it has not yet been initialized.
pub fn borrow_mut(&mut self) -> Option<&mut T> {
match self.state.load(Ordering::Acquire) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Atomic op seems confusing here, perhaps get_mut will be more clear? https://doc.rust-lang.org/std/sync/atomic/struct.AtomicUsize.html#method.get_mut

Copy link
Owner

Choose a reason for hiding this comment

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

@matklad sorry to necrobump this PR, but could you expand on why the atomic op is confusing? I'm not very well acquainted with the atomic operations.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is confusing in a sense that we do atomic load when we don’t need one. We have &mut anyway, so additional synchronization power which comes from atomic load is unnecessary. Using extra power when there’s no need for it confuses me, as I think that there should be some real reason for it.

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