about summary refs log tree commit diff
path: root/src/libcore/atomic.rs
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2014-12-22 12:29:46 +0100
committerFlavio Percoco <flaper87@gmail.com>2014-12-26 17:26:33 +0100
commite2116c8fba6e73bc2bbf7cb6bb41911d4daed043 (patch)
tree5484f1e0a4b7dfad3f2a363e5db1a39c9b50ccc9 /src/libcore/atomic.rs
parentf436f9ca2963e33cc41802370bb9c551c833970e (diff)
downloadrust-e2116c8fba6e73bc2bbf7cb6bb41911d4daed043.tar.gz
rust-e2116c8fba6e73bc2bbf7cb6bb41911d4daed043.zip
Move RacyCell to `std::comm`
RacyCell is not exactly what we'd like as a final implementation for
this. Therefore, we're moving it under `std::comm` and also making it
private.
Diffstat (limited to 'src/libcore/atomic.rs')
-rw-r--r--src/libcore/atomic.rs34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs
index a34f13d127c..9452d0a64bf 100644
--- a/src/libcore/atomic.rs
+++ b/src/libcore/atomic.rs
@@ -14,33 +14,43 @@
 
 pub use self::Ordering::*;
 
+use kinds::Sync;
+
 use intrinsics;
-use cell::{UnsafeCell, RacyCell};
+use cell::UnsafeCell;
 
 /// A boolean type which can be safely shared between threads.
 #[stable]
 pub struct AtomicBool {
-    v: RacyCell<uint>,
+    v: UnsafeCell<uint>,
 }
 
+unsafe impl Sync for AtomicBool {}
+
 /// A signed integer type which can be safely shared between threads.
 #[stable]
 pub struct AtomicInt {
-    v: RacyCell<int>,
+    v: UnsafeCell<int>,
 }
 
+unsafe impl Sync for AtomicInt {}
+
 /// An unsigned integer type which can be safely shared between threads.
 #[stable]
 pub struct AtomicUint {
-    v: RacyCell<uint>,
+    v: UnsafeCell<uint>,
 }
 
+unsafe impl Sync for AtomicUint {}
+
 /// A raw pointer type which can be safely shared between threads.
 #[stable]
 pub struct AtomicPtr<T> {
-    p: RacyCell<uint>,
+    p: UnsafeCell<uint>,
 }
 
+unsafe impl<T> Sync for AtomicPtr<T> {}
+
 /// Atomic memory orderings
 ///
 /// Memory orderings limit the ways that both the compiler and CPU may reorder
@@ -80,15 +90,15 @@ pub enum Ordering {
 /// An `AtomicBool` initialized to `false`.
 #[unstable = "may be renamed, pending conventions for static initalizers"]
 pub const INIT_ATOMIC_BOOL: AtomicBool =
-        AtomicBool { v: RacyCell(UnsafeCell { value: 0 }) };
+        AtomicBool { v: UnsafeCell { value: 0 } };
 /// An `AtomicInt` initialized to `0`.
 #[unstable = "may be renamed, pending conventions for static initalizers"]
 pub const INIT_ATOMIC_INT: AtomicInt =
-        AtomicInt { v: RacyCell(UnsafeCell { value: 0 }) };
+        AtomicInt { v: UnsafeCell { value: 0 } };
 /// An `AtomicUint` initialized to `0`.
 #[unstable = "may be renamed, pending conventions for static initalizers"]
 pub const INIT_ATOMIC_UINT: AtomicUint =
-        AtomicUint { v: RacyCell(UnsafeCell { value: 0 }) };
+        AtomicUint { v: UnsafeCell { value: 0, } };
 
 // NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
 const UINT_TRUE: uint = -1;
@@ -108,7 +118,7 @@ impl AtomicBool {
     #[stable]
     pub fn new(v: bool) -> AtomicBool {
         let val = if v { UINT_TRUE } else { 0 };
-        AtomicBool { v: RacyCell::new(val) }
+        AtomicBool { v: UnsafeCell::new(val) }
     }
 
     /// Loads a value from the bool.
@@ -348,7 +358,7 @@ impl AtomicInt {
     #[inline]
     #[stable]
     pub fn new(v: int) -> AtomicInt {
-        AtomicInt {v: RacyCell::new(v)}
+        AtomicInt {v: UnsafeCell::new(v)}
     }
 
     /// Loads a value from the int.
@@ -534,7 +544,7 @@ impl AtomicUint {
     #[inline]
     #[stable]
     pub fn new(v: uint) -> AtomicUint {
-        AtomicUint { v: RacyCell::new(v) }
+        AtomicUint { v: UnsafeCell::new(v) }
     }
 
     /// Loads a value from the uint.
@@ -721,7 +731,7 @@ impl<T> AtomicPtr<T> {
     #[inline]
     #[stable]
     pub fn new(p: *mut T) -> AtomicPtr<T> {
-        AtomicPtr { p: RacyCell::new(p as uint) }
+        AtomicPtr { p: UnsafeCell::new(p as uint) }
     }
 
     /// Loads a value from the pointer.