feat(atomic): implement borrow_mut for AtomicLazyCell#97
feat(atomic): implement borrow_mut for AtomicLazyCell#97dignifiedquire wants to merge 1 commit intoindiv0:masterfrom
Conversation
|
Thanks! Feel free to add yourself to the |
| /// 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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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.
No description provided.