From 29b3698f7faf5257b44b51cd2d00438e927434b7 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Wed, 24 Dec 2014 09:48:11 +0100 Subject: [PATCH] Implement Sync/Send for ArcInner and Weak --- src/liballoc/arc.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 3d10628b1cb..8d8bbb42932 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -117,6 +117,10 @@ pub struct Arc { _ptr: *mut ArcInner, } +unsafe impl Send for Arc { } +unsafe impl Sync for Arc { } + + /// A weak pointer to an `Arc`. /// /// Weak pointers will not keep the data inside of the `Arc` alive, and can be used to break cycles @@ -129,9 +133,8 @@ pub struct Weak { _ptr: *mut ArcInner, } -unsafe impl Send for Arc { } - -unsafe impl Sync for Arc { } +unsafe impl Send for Weak { } +unsafe impl Sync for Weak { } struct ArcInner { strong: atomic::AtomicUint, @@ -139,6 +142,9 @@ struct ArcInner { data: T, } +unsafe impl Send for ArcInner {} +unsafe impl Sync for ArcInner {} + impl Arc { /// Constructs a new `Arc`. /// @@ -591,6 +597,7 @@ mod tests { use std::str::Str; use std::sync::atomic; use std::task; + use std::kinds::Send; use std::vec::Vec; use super::{Arc, Weak, weak_count, strong_count}; use std::sync::Mutex;