Add a copy-on-write container.
This commit is contained in:
parent
5ff7b28373
commit
06a8d59ded
2 changed files with 116 additions and 0 deletions
|
|
@ -94,6 +94,14 @@ impl<T: Send> UnsafeArc<T> {
|
|||
return &(*self.data).data as *T;
|
||||
}
|
||||
}
|
||||
|
||||
/// checks if this is the only reference to the arc protected data
|
||||
#[inline]
|
||||
pub fn is_owned(&self) -> bool {
|
||||
unsafe {
|
||||
(*self.data).count.load(Relaxed) == 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> Clone for UnsafeArc<T> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue