From 06a8d59ded67dfaa589112ceb8a8e031bc575249 Mon Sep 17 00:00:00 2001 From: Colin Sherratt Date: Mon, 30 Dec 2013 19:17:35 -0500 Subject: Add a copy-on-write container. --- src/libstd/sync/arc.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libstd/sync') diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs index 7b94a3acc2b..5c452018b9b 100644 --- a/src/libstd/sync/arc.rs +++ b/src/libstd/sync/arc.rs @@ -94,6 +94,14 @@ impl UnsafeArc { 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 Clone for UnsafeArc { -- cgit 1.4.1-3-g733a5