about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorColin Sherratt <colin.sherratt@gmail.com>2013-12-30 19:17:35 -0500
committerColin Sherratt <colin.sherratt@gmail.com>2013-12-31 14:31:23 -0500
commit06a8d59ded67dfaa589112ceb8a8e031bc575249 (patch)
treec53ff4a39cc4f05a4a2d951dfdf6ace174d02de0 /src/libstd/sync
parent5ff7b283731b795930d1e6782ae1639c83595e91 (diff)
downloadrust-06a8d59ded67dfaa589112ceb8a8e031bc575249.tar.gz
rust-06a8d59ded67dfaa589112ceb8a8e031bc575249.zip
Add a copy-on-write container.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/arc.rs8
1 files changed, 8 insertions, 0 deletions
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<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> {