about summary refs log tree commit diff
path: root/src/libsync
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsync')
-rw-r--r--src/libsync/comm/mod.rs42
-rw-r--r--src/libsync/comm/sync.rs6
-rw-r--r--src/libsync/lock.rs18
-rw-r--r--src/libsync/mpmc_bounded_queue.rs6
-rw-r--r--src/libsync/mpsc_intrusive.rs6
-rw-r--r--src/libsync/mpsc_queue.rs6
-rw-r--r--src/libsync/mutex.rs26
-rw-r--r--src/libsync/raw.rs6
-rw-r--r--src/libsync/spsc_queue.rs18
9 files changed, 67 insertions, 67 deletions
diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs
index 2aec3952125..eff4cea1c43 100644
--- a/src/libsync/comm/mod.rs
+++ b/src/libsync/comm/mod.rs
@@ -324,7 +324,7 @@ use alloc::boxed::Box;
 use core::cell::Cell;
 use core::kinds::marker;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 use rustrt::local::Local;
 use rustrt::task::{Task, BlockedTask};
 
@@ -372,7 +372,7 @@ static RESCHED_FREQ: int = 256;
 /// one task
 #[unstable]
 pub struct Receiver<T> {
-    inner: Unsafe<Flavor<T>>,
+    inner: UnsafeCell<Flavor<T>>,
     receives: Cell<uint>,
     // can't share in an arc
     marker: marker::NoShare,
@@ -390,7 +390,7 @@ pub struct Messages<'a, T> {
 /// owned by one task, but it can be cloned to send to other tasks.
 #[unstable]
 pub struct Sender<T> {
-    inner: Unsafe<Flavor<T>>,
+    inner: UnsafeCell<Flavor<T>>,
     sends: Cell<uint>,
     // can't share in an arc
     marker: marker::NoShare,
@@ -400,7 +400,7 @@ pub struct Sender<T> {
 /// owned by one task, but it can be cloned to send to other tasks.
 #[unstable = "this type may be renamed, but it will always exist"]
 pub struct SyncSender<T> {
-    inner: Arc<Unsafe<sync::Packet<T>>>,
+    inner: Arc<UnsafeCell<sync::Packet<T>>>,
     // can't share in an arc
     marker: marker::NoShare,
 }
@@ -436,15 +436,15 @@ pub enum TrySendError<T> {
 }
 
 enum Flavor<T> {
-    Oneshot(Arc<Unsafe<oneshot::Packet<T>>>),
-    Stream(Arc<Unsafe<stream::Packet<T>>>),
-    Shared(Arc<Unsafe<shared::Packet<T>>>),
-    Sync(Arc<Unsafe<sync::Packet<T>>>),
+    Oneshot(Arc<UnsafeCell<oneshot::Packet<T>>>),
+    Stream(Arc<UnsafeCell<stream::Packet<T>>>),
+    Shared(Arc<UnsafeCell<shared::Packet<T>>>),
+    Sync(Arc<UnsafeCell<sync::Packet<T>>>),
 }
 
 #[doc(hidden)]
 trait UnsafeFlavor<T> {
-    fn inner_unsafe<'a>(&'a self) -> &'a Unsafe<Flavor<T>>;
+    fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>;
     unsafe fn mut_inner<'a>(&'a self) -> &'a mut Flavor<T> {
         &mut *self.inner_unsafe().get()
     }
@@ -453,12 +453,12 @@ trait UnsafeFlavor<T> {
     }
 }
 impl<T> UnsafeFlavor<T> for Sender<T> {
-    fn inner_unsafe<'a>(&'a self) -> &'a Unsafe<Flavor<T>> {
+    fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
         &self.inner
     }
 }
 impl<T> UnsafeFlavor<T> for Receiver<T> {
-    fn inner_unsafe<'a>(&'a self) -> &'a Unsafe<Flavor<T>> {
+    fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
         &self.inner
     }
 }
@@ -486,7 +486,7 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
 /// ```
 #[unstable]
 pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
-    let a = Arc::new(Unsafe::new(oneshot::Packet::new()));
+    let a = Arc::new(UnsafeCell::new(oneshot::Packet::new()));
     (Sender::new(Oneshot(a.clone())), Receiver::new(Oneshot(a)))
 }
 
@@ -524,7 +524,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
 #[unstable = "this function may be renamed to more accurately reflect the type \
               of channel that is is creating"]
 pub fn sync_channel<T: Send>(bound: uint) -> (SyncSender<T>, Receiver<T>) {
-    let a = Arc::new(Unsafe::new(sync::Packet::new(bound)));
+    let a = Arc::new(UnsafeCell::new(sync::Packet::new(bound)));
     (SyncSender::new(a.clone()), Receiver::new(Sync(a)))
 }
 
@@ -534,7 +534,11 @@ pub fn sync_channel<T: Send>(bound: uint) -> (SyncSender<T>, Receiver<T>) {
 
 impl<T: Send> Sender<T> {
     fn new(inner: Flavor<T>) -> Sender<T> {
-        Sender { inner: Unsafe::new(inner), sends: Cell::new(0), marker: marker::NoShare }
+        Sender {
+            inner: UnsafeCell::new(inner),
+            sends: Cell::new(0),
+            marker: marker::NoShare,
+        }
     }
 
     /// Sends a value along this channel to be received by the corresponding
@@ -618,7 +622,7 @@ impl<T: Send> Sender<T> {
                     if !(*p).sent() {
                         return (*p).send(t);
                     } else {
-                        let a = Arc::new(Unsafe::new(stream::Packet::new()));
+                        let a = Arc::new(UnsafeCell::new(stream::Packet::new()));
                         match (*p).upgrade(Receiver::new(Stream(a.clone()))) {
                             oneshot::UpSuccess => {
                                 let ret = (*a.get()).send(t);
@@ -655,7 +659,7 @@ impl<T: Send> Clone for Sender<T> {
     fn clone(&self) -> Sender<T> {
         let (packet, sleeper) = match *unsafe { self.inner() } {
             Oneshot(ref p) => {
-                let a = Arc::new(Unsafe::new(shared::Packet::new()));
+                let a = Arc::new(UnsafeCell::new(shared::Packet::new()));
                 unsafe {
                     (*a.get()).postinit_lock();
                     match (*p.get()).upgrade(Receiver::new(Shared(a.clone()))) {
@@ -665,7 +669,7 @@ impl<T: Send> Clone for Sender<T> {
                 }
             }
             Stream(ref p) => {
-                let a = Arc::new(Unsafe::new(shared::Packet::new()));
+                let a = Arc::new(UnsafeCell::new(shared::Packet::new()));
                 unsafe {
                     (*a.get()).postinit_lock();
                     match (*p.get()).upgrade(Receiver::new(Shared(a.clone()))) {
@@ -708,7 +712,7 @@ impl<T: Send> Drop for Sender<T> {
 ////////////////////////////////////////////////////////////////////////////////
 
 impl<T: Send> SyncSender<T> {
-    fn new(inner: Arc<Unsafe<sync::Packet<T>>>) -> SyncSender<T> {
+    fn new(inner: Arc<UnsafeCell<sync::Packet<T>>>) -> SyncSender<T> {
         SyncSender { inner: inner, marker: marker::NoShare }
     }
 
@@ -797,7 +801,7 @@ impl<T: Send> Drop for SyncSender<T> {
 
 impl<T: Send> Receiver<T> {
     fn new(inner: Flavor<T>) -> Receiver<T> {
-        Receiver { inner: Unsafe::new(inner), receives: Cell::new(0), marker: marker::NoShare }
+        Receiver { inner: UnsafeCell::new(inner), receives: Cell::new(0), marker: marker::NoShare }
     }
 
     /// Blocks waiting for a value on this receiver
diff --git a/src/libsync/comm/sync.rs b/src/libsync/comm/sync.rs
index 1d5a7d6ed9f..e872952d9ee 100644
--- a/src/libsync/comm/sync.rs
+++ b/src/libsync/comm/sync.rs
@@ -39,7 +39,7 @@ use alloc::boxed::Box;
 use collections::Vec;
 use collections::Collection;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 use rustrt::local::Local;
 use rustrt::mutex::{NativeMutex, LockGuard};
 use rustrt::task::{Task, BlockedTask};
@@ -53,7 +53,7 @@ pub struct Packet<T> {
 
     /// The state field is protected by this mutex
     lock: NativeMutex,
-    state: Unsafe<State<T>>,
+    state: UnsafeCell<State<T>>,
 }
 
 struct State<T> {
@@ -133,7 +133,7 @@ impl<T: Send> Packet<T> {
         Packet {
             channels: atomics::AtomicUint::new(1),
             lock: unsafe { NativeMutex::new() },
-            state: Unsafe::new(State {
+            state: UnsafeCell::new(State {
                 disconnected: false,
                 blocker: NoneBlocked,
                 cap: cap,
diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs
index 1d119bafea1..e8418f9668f 100644
--- a/src/libsync/lock.rs
+++ b/src/libsync/lock.rs
@@ -21,7 +21,7 @@
 
 use core::prelude::*;
 
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 use rustrt::local::Local;
 use rustrt::task::Task;
 
@@ -174,8 +174,8 @@ impl<'a> Condvar<'a> {
 /// ```
 pub struct Mutex<T> {
     lock: raw::Mutex,
-    failed: Unsafe<bool>,
-    data: Unsafe<T>,
+    failed: UnsafeCell<bool>,
+    data: UnsafeCell<T>,
 }
 
 /// An guard which is created by locking a mutex. Through this guard the
@@ -203,8 +203,8 @@ impl<T: Send> Mutex<T> {
     pub fn new_with_condvars(user_data: T, num_condvars: uint) -> Mutex<T> {
         Mutex {
             lock: raw::Mutex::new_with_condvars(num_condvars),
-            failed: Unsafe::new(false),
-            data: Unsafe::new(user_data),
+            failed: UnsafeCell::new(false),
+            data: UnsafeCell::new(user_data),
         }
     }
 
@@ -274,8 +274,8 @@ impl<'a, T: Send> DerefMut<T> for MutexGuard<'a, T> {
 /// ```
 pub struct RWLock<T> {
     lock: raw::RWLock,
-    failed: Unsafe<bool>,
-    data: Unsafe<T>,
+    failed: UnsafeCell<bool>,
+    data: UnsafeCell<T>,
 }
 
 /// A guard which is created by locking an rwlock in write mode. Through this
@@ -309,8 +309,8 @@ impl<T: Send + Share> RWLock<T> {
     pub fn new_with_condvars(user_data: T, num_condvars: uint) -> RWLock<T> {
         RWLock {
             lock: raw::RWLock::new_with_condvars(num_condvars),
-            failed: Unsafe::new(false),
-            data: Unsafe::new(user_data),
+            failed: UnsafeCell::new(false),
+            data: UnsafeCell::new(user_data),
         }
     }
 
diff --git a/src/libsync/mpmc_bounded_queue.rs b/src/libsync/mpmc_bounded_queue.rs
index 7343838f19e..d54186dc221 100644
--- a/src/libsync/mpmc_bounded_queue.rs
+++ b/src/libsync/mpmc_bounded_queue.rs
@@ -35,7 +35,7 @@ use core::prelude::*;
 use alloc::arc::Arc;
 use collections::Vec;
 use core::num::next_power_of_two;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 
 use atomics::{AtomicUint,Relaxed,Release,Acquire};
 
@@ -46,7 +46,7 @@ struct Node<T> {
 
 struct State<T> {
     pad0: [u8, ..64],
-    buffer: Vec<Unsafe<Node<T>>>,
+    buffer: Vec<UnsafeCell<Node<T>>>,
     mask: uint,
     pad1: [u8, ..64],
     enqueue_pos: AtomicUint,
@@ -72,7 +72,7 @@ impl<T: Send> State<T> {
             capacity
         };
         let buffer = Vec::from_fn(capacity, |i| {
-            Unsafe::new(Node { sequence:AtomicUint::new(i), value: None })
+            UnsafeCell::new(Node { sequence:AtomicUint::new(i), value: None })
         });
         State{
             pad0: [0, ..64],
diff --git a/src/libsync/mpsc_intrusive.rs b/src/libsync/mpsc_intrusive.rs
index 2b6886ab7f4..11f124293b1 100644
--- a/src/libsync/mpsc_intrusive.rs
+++ b/src/libsync/mpsc_intrusive.rs
@@ -39,7 +39,7 @@ use core::prelude::*;
 
 use core::atomics;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 
 // NB: all links are done as AtomicUint instead of AtomicPtr to allow for static
 // initialization.
@@ -55,7 +55,7 @@ pub struct DummyNode {
 
 pub struct Queue<T> {
     pub head: atomics::AtomicUint,
-    pub tail: Unsafe<*mut Node<T>>,
+    pub tail: UnsafeCell<*mut Node<T>>,
     pub stub: DummyNode,
 }
 
@@ -63,7 +63,7 @@ impl<T: Send> Queue<T> {
     pub fn new() -> Queue<T> {
         Queue {
             head: atomics::AtomicUint::new(0),
-            tail: Unsafe::new(0 as *mut Node<T>),
+            tail: UnsafeCell::new(0 as *mut Node<T>),
             stub: DummyNode {
                 next: atomics::AtomicUint::new(0),
             },
diff --git a/src/libsync/mpsc_queue.rs b/src/libsync/mpsc_queue.rs
index 759695fe5b6..4f5dd07a6e5 100644
--- a/src/libsync/mpsc_queue.rs
+++ b/src/libsync/mpsc_queue.rs
@@ -44,7 +44,7 @@ use core::prelude::*;
 
 use alloc::boxed::Box;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 
 use atomics::{AtomicPtr, Release, Acquire, AcqRel, Relaxed};
 
@@ -71,7 +71,7 @@ struct Node<T> {
 /// popper at a time (many pushers are allowed).
 pub struct Queue<T> {
     head: AtomicPtr<Node<T>>,
-    tail: Unsafe<*mut Node<T>>,
+    tail: UnsafeCell<*mut Node<T>>,
 }
 
 impl<T> Node<T> {
@@ -90,7 +90,7 @@ impl<T: Send> Queue<T> {
         let stub = unsafe { Node::new(None) };
         Queue {
             head: AtomicPtr::new(stub),
-            tail: Unsafe::new(stub),
+            tail: UnsafeCell::new(stub),
         }
     }
 
diff --git a/src/libsync/mutex.rs b/src/libsync/mutex.rs
index 990d743465d..1aa84e8f8d1 100644
--- a/src/libsync/mutex.rs
+++ b/src/libsync/mutex.rs
@@ -61,9 +61,8 @@ use core::prelude::*;
 
 use alloc::boxed::Box;
 use core::atomics;
-use core::kinds::marker;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 use rustrt::local::Local;
 use rustrt::mutex;
 use rustrt::task::{BlockedTask, Task};
@@ -143,11 +142,11 @@ pub struct StaticMutex {
     lock: mutex::StaticNativeMutex,
 
     /// Type of locking operation currently on this mutex
-    flavor: Unsafe<Flavor>,
+    flavor: UnsafeCell<Flavor>,
     /// uint-cast of the green thread waiting for this mutex
-    green_blocker: Unsafe<uint>,
+    green_blocker: UnsafeCell<uint>,
     /// uint-cast of the native thread waiting for this mutex
-    native_blocker: Unsafe<uint>,
+    native_blocker: UnsafeCell<uint>,
 
     /// A concurrent mpsc queue used by green threads, along with a count used
     /// to figure out when to dequeue and enqueue.
@@ -167,16 +166,13 @@ pub struct Guard<'a> {
 pub static MUTEX_INIT: StaticMutex = StaticMutex {
     lock: mutex::NATIVE_MUTEX_INIT,
     state: atomics::INIT_ATOMIC_UINT,
-    flavor: Unsafe { value: Unlocked, marker1: marker::InvariantType },
-    green_blocker: Unsafe { value: 0, marker1: marker::InvariantType },
-    native_blocker: Unsafe { value: 0, marker1: marker::InvariantType },
+    flavor: UnsafeCell { value: Unlocked },
+    green_blocker: UnsafeCell { value: 0 },
+    native_blocker: UnsafeCell { value: 0 },
     green_cnt: atomics::INIT_ATOMIC_UINT,
     q: q::Queue {
         head: atomics::INIT_ATOMIC_UINT,
-        tail: Unsafe {
-            value: 0 as *mut q::Node<uint>,
-            marker1: marker::InvariantType,
-        },
+        tail: UnsafeCell { value: 0 as *mut q::Node<uint> },
         stub: q::DummyNode {
             next: atomics::INIT_ATOMIC_UINT,
         }
@@ -467,9 +463,9 @@ impl Mutex {
         Mutex {
             lock: box StaticMutex {
                 state: atomics::AtomicUint::new(0),
-                flavor: Unsafe::new(Unlocked),
-                green_blocker: Unsafe::new(0),
-                native_blocker: Unsafe::new(0),
+                flavor: UnsafeCell::new(Unlocked),
+                green_blocker: UnsafeCell::new(0),
+                native_blocker: UnsafeCell::new(0),
                 green_cnt: atomics::AtomicUint::new(0),
                 q: q::Queue::new(),
                 lock: unsafe { mutex::StaticNativeMutex::new() },
diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs
index cb047798946..e7a2d3e0639 100644
--- a/src/libsync/raw.rs
+++ b/src/libsync/raw.rs
@@ -21,7 +21,7 @@ use core::atomics;
 use core::finally::Finally;
 use core::kinds::marker;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 use collections::{Vec, MutableSeq};
 
 use mutex;
@@ -91,7 +91,7 @@ struct Sem<Q> {
     //      (for good reason). We have an internal invariant on this semaphore,
     //      however, that the queue is never accessed outside of a locked
     //      context.
-    inner: Unsafe<SemInner<Q>>
+    inner: UnsafeCell<SemInner<Q>>
 }
 
 struct SemInner<Q> {
@@ -113,7 +113,7 @@ impl<Q: Send> Sem<Q> {
                 "semaphores cannot be initialized with negative values");
         Sem {
             lock: mutex::Mutex::new(),
-            inner: Unsafe::new(SemInner {
+            inner: UnsafeCell::new(SemInner {
                 waiters: WaitQueue::new(),
                 count: count,
                 blocked: q,
diff --git a/src/libsync/spsc_queue.rs b/src/libsync/spsc_queue.rs
index cf4d3222ed0..0cda1098ab4 100644
--- a/src/libsync/spsc_queue.rs
+++ b/src/libsync/spsc_queue.rs
@@ -39,7 +39,7 @@ use core::prelude::*;
 
 use alloc::boxed::Box;
 use core::mem;
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 
 use atomics::{AtomicPtr, Relaxed, AtomicUint, Acquire, Release};
 
@@ -58,13 +58,13 @@ struct Node<T> {
 /// time.
 pub struct Queue<T> {
     // consumer fields
-    tail: Unsafe<*mut Node<T>>, // where to pop from
+    tail: UnsafeCell<*mut Node<T>>, // where to pop from
     tail_prev: AtomicPtr<Node<T>>, // where to pop from
 
     // producer fields
-    head: Unsafe<*mut Node<T>>,      // where to push to
-    first: Unsafe<*mut Node<T>>,     // where to get new nodes from
-    tail_copy: Unsafe<*mut Node<T>>, // between first/tail
+    head: UnsafeCell<*mut Node<T>>,      // where to push to
+    first: UnsafeCell<*mut Node<T>>,     // where to get new nodes from
+    tail_copy: UnsafeCell<*mut Node<T>>, // between first/tail
 
     // Cache maintenance fields. Additions and subtractions are stored
     // separately in order to allow them to use nonatomic addition/subtraction.
@@ -103,11 +103,11 @@ impl<T: Send> Queue<T> {
         let n2 = Node::new();
         unsafe { (*n1).next.store(n2, Relaxed) }
         Queue {
-            tail: Unsafe::new(n2),
+            tail: UnsafeCell::new(n2),
             tail_prev: AtomicPtr::new(n1),
-            head: Unsafe::new(n2),
-            first: Unsafe::new(n1),
-            tail_copy: Unsafe::new(n1),
+            head: UnsafeCell::new(n2),
+            first: UnsafeCell::new(n1),
+            tail_copy: UnsafeCell::new(n1),
             cache_bound: bound,
             cache_additions: AtomicUint::new(0),
             cache_subtractions: AtomicUint::new(0),