diff options
| author | Colin Sherratt <colin.sherratt@gmail.com> | 2013-12-30 19:17:35 -0500 |
|---|---|---|
| committer | Colin Sherratt <colin.sherratt@gmail.com> | 2013-12-31 14:31:23 -0500 |
| commit | 06a8d59ded67dfaa589112ceb8a8e031bc575249 (patch) | |
| tree | c53ff4a39cc4f05a4a2d951dfdf6ace174d02de0 /src/libstd/sync | |
| parent | 5ff7b283731b795930d1e6782ae1639c83595e91 (diff) | |
| download | rust-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.rs | 8 |
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> { |
