Add a copy-on-write container.

This commit is contained in:
Colin Sherratt 2013-12-30 19:17:35 -05:00
parent 5ff7b28373
commit 06a8d59ded
2 changed files with 116 additions and 0 deletions

View file

@ -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> {