about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2014-12-24 09:48:11 +0100
committerFlavio Percoco <flaper87@gmail.com>2014-12-26 17:26:33 +0100
commit29b3698f7faf5257b44b51cd2d00438e927434b7 (patch)
tree8eb8f322ba9192127c7cc76218d7794d2fa08f14 /src/liballoc
parent84a6684c6532600cb761e10998a75d8a5308790e (diff)
downloadrust-29b3698f7faf5257b44b51cd2d00438e927434b7.tar.gz
rust-29b3698f7faf5257b44b51cd2d00438e927434b7.zip
Implement Sync/Send for ArcInner and Weak
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs13
1 files 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<T> {
     _ptr: *mut ArcInner<T>,
 }
 
+unsafe impl<T: Sync + Send> Send for Arc<T> { }
+unsafe impl<T: Sync + Send> Sync for Arc<T> { }
+
+
 /// 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<T> {
     _ptr: *mut ArcInner<T>,
 }
 
-unsafe impl<T: Sync + Send> Send for Arc<T> { }
-
-unsafe impl<T: Sync + Send> Sync for Arc<T> { }
+unsafe impl<T: Sync + Send> Send for Weak<T> { }
+unsafe impl<T: Sync + Send> Sync for Weak<T> { }
 
 struct ArcInner<T> {
     strong: atomic::AtomicUint,
@@ -139,6 +142,9 @@ struct ArcInner<T> {
     data: T,
 }
 
+unsafe impl<T: Sync + Send> Send for ArcInner<T> {}
+unsafe impl<T: Sync + Send> Sync for ArcInner<T> {}
+
 impl<T> Arc<T> {
     /// Constructs a new `Arc<T>`.
     ///
@@ -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;