Skip to content

Commit

Permalink
📝 add take for RcuWeak
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Dec 27, 2024
1 parent 70cee0d commit 72bcc95
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rcu_weak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ impl<T> RcuWeak<T> {
ret
}

/// take the value from the rcu weak, leave the rcu weak with default value
#[inline]
pub fn take(&self) -> Weak<T> {
ptr_to_weak(self.link.update(ptr::null()))
}

/// write a new weak value to the rcu weak cell and return the old value
#[inline]
pub fn write(&self, data: Weak<T>) -> Weak<T> {
Expand Down

0 comments on commit 72bcc95

Please sign in to comment.