about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-08-29 20:23:29 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-08-29 20:29:02 -0400
commit05bb4c4e1bea99295f93d9a2382f534d675daee0 (patch)
tree851c8d231657d665d5208f62ecc3a2fc8f61a976 /src/libstd
parent698873e3a829d764b451f657178403c704044721 (diff)
downloadrust-05bb4c4e1bea99295f93d9a2382f534d675daee0.tar.gz
rust-05bb4c4e1bea99295f93d9a2382f534d675daee0.zip
reduce the size of UnsafeArc from 2 words to 1
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/unstable/sync.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs
index 8d1545ea2b4..26313323291 100644
--- a/src/libstd/unstable/sync.rs
+++ b/src/libstd/unstable/sync.rs
@@ -26,6 +26,7 @@ use vec;
 /// An atomically reference counted pointer.
 ///
 /// Enforces no shared-memory safety.
+#[unsafe_no_drop_flag]
 pub struct UnsafeArc<T> {
     data: *mut ArcData<T>,
 }
@@ -221,8 +222,9 @@ impl<T: Send> Clone for UnsafeArc<T> {
 impl<T> Drop for UnsafeArc<T>{
     fn drop(&self) {
         unsafe {
+            // Happens when destructing an unwrapper's handle and from `#[unsafe_no_drop_flag]`
             if self.data.is_null() {
-                return; // Happens when destructing an unwrapper's handle.
+                return
             }
             let mut data: ~ArcData<T> = cast::transmute(self.data);
             // Must be acquire+release, not just release, to make sure this
@@ -440,6 +442,12 @@ mod tests {
     use super::{Exclusive, UnsafeArc, atomically};
     use task;
     use util;
+    use sys::size_of;
+
+    #[test]
+    fn test_size() {
+        assert_eq!(size_of::<UnsafeArc<[int, ..10]>>(), size_of::<*[int, ..10]>());
+    }
 
     #[test]
     fn test_atomically() {