about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-05-07 05:16:48 -0700
committerbors <bors@rust-lang.org>2014-05-07 05:16:48 -0700
commitef6daf9935da103f1b915a5c9904794da79b0b60 (patch)
treead9695f06d85962039a8f90ac741726b345096aa /src/libstd/sync
parent4a5d39001b1da84fe4be2996a2c7d894d5c248c6 (diff)
parent090040bf4037a094e50b03d79e4baf5cd89c912b (diff)
downloadrust-ef6daf9935da103f1b915a5c9904794da79b0b60.tar.gz
rust-ef6daf9935da103f1b915a5c9904794da79b0b60.zip
auto merge of #13958 : pcwalton/rust/detilde, r=pcwalton
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

r? @brson or @alexcrichton or whoever
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/arc.rs3
-rw-r--r--src/libstd/sync/atomics.rs11
-rw-r--r--src/libstd/sync/deque.rs21
-rw-r--r--src/libstd/sync/mpsc_queue.rs5
-rw-r--r--src/libstd/sync/spsc_queue.rs5
5 files changed, 26 insertions, 19 deletions
diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs
index 0cf975a4c1c..d277c514e44 100644
--- a/src/libstd/sync/arc.rs
+++ b/src/libstd/sync/arc.rs
@@ -26,6 +26,7 @@ use clone::Clone;
 use iter::Iterator;
 use kinds::Send;
 use ops::Drop;
+use owned::Box;
 use ptr::RawPtr;
 use sync::atomics::{fence, AtomicUint, Relaxed, Acquire, Release};
 use ty::Unsafe;
@@ -157,7 +158,7 @@ impl<T> Drop for UnsafeArc<T>{
                 //  happened before), and an "acquire" operation before deleting the object.
                 // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
                 fence(Acquire);
-                let _: ~ArcData<T> = cast::transmute(self.data);
+                let _: Box<ArcData<T>> = cast::transmute(self.data);
             }
         }
     }
diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs
index a3c1c33f77c..2fba59c3233 100644
--- a/src/libstd/sync/atomics.rs
+++ b/src/libstd/sync/atomics.rs
@@ -88,7 +88,7 @@
 //!         }
 //!     });
 //!
-//!     shared_big_object.swap(~BigObject, SeqCst);
+//!     shared_big_object.swap(box BigObject, SeqCst);
 //! }
 //! ```
 //!
@@ -112,6 +112,7 @@ use cast;
 use std::kinds::marker;
 use option::{Option,Some,None};
 use ops::Drop;
+use owned::Box;
 use ty::Unsafe;
 
 /// An atomic boolean type.
@@ -663,7 +664,7 @@ impl<T> AtomicPtr<T> {
 
 impl<T> AtomicOption<T> {
     /// Create a new `AtomicOption`
-    pub fn new(p: ~T) -> AtomicOption<T> {
+    pub fn new(p: Box<T>) -> AtomicOption<T> {
         unsafe { AtomicOption { p: Unsafe::new(cast::transmute(p)) } }
     }
 
@@ -672,7 +673,7 @@ impl<T> AtomicOption<T> {
 
     /// Store a value, returning the old value
     #[inline]
-    pub fn swap(&self, val: ~T, order: Ordering) -> Option<~T> {
+    pub fn swap(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
         unsafe {
             let val = cast::transmute(val);
 
@@ -687,7 +688,7 @@ impl<T> AtomicOption<T> {
 
     /// Remove the value, leaving the `AtomicOption` empty.
     #[inline]
-    pub fn take(&self, order: Ordering) -> Option<~T> {
+    pub fn take(&self, order: Ordering) -> Option<Box<T>> {
         unsafe { self.swap(cast::transmute(0), order) }
     }
 
@@ -697,7 +698,7 @@ impl<T> AtomicOption<T> {
     /// the option was already `Some`, returns `Some` of the rejected
     /// value.
     #[inline]
-    pub fn fill(&self, val: ~T, order: Ordering) -> Option<~T> {
+    pub fn fill(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
         unsafe {
             let val = cast::transmute(val);
             let expected = cast::transmute(0);
diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs
index 22ed66b708b..d06062f02ac 100644
--- a/src/libstd/sync/deque.rs
+++ b/src/libstd/sync/deque.rs
@@ -56,6 +56,7 @@ use libc;
 use mem;
 use ops::Drop;
 use option::{Option, Some, None};
+use owned::Box;
 use ptr;
 use ptr::RawPtr;
 use sync::arc::UnsafeArc;
@@ -117,7 +118,7 @@ pub enum Stolen<T> {
 /// will only use this structure when allocating a new buffer or deallocating a
 /// previous one.
 pub struct BufferPool<T> {
-    pool: Exclusive<Vec<~Buffer<T>>>,
+    pool: Exclusive<Vec<Box<Buffer<T>>>>,
 }
 
 /// An internal buffer used by the chase-lev deque. This structure is actually
@@ -154,7 +155,7 @@ impl<T: Send> BufferPool<T> {
         (Worker { deque: a }, Stealer { deque: b })
     }
 
-    fn alloc(&mut self, bits: int) -> ~Buffer<T> {
+    fn alloc(&mut self, bits: int) -> Box<Buffer<T>> {
         unsafe {
             self.pool.with(|pool| {
                 match pool.iter().position(|x| x.size() >= (1 << bits)) {
@@ -165,7 +166,7 @@ impl<T: Send> BufferPool<T> {
         }
     }
 
-    fn free(&mut self, buf: ~Buffer<T>) {
+    fn free(&mut self, buf: Box<Buffer<T>>) {
         unsafe {
             let mut buf = Some(buf);
             self.pool.with(|pool| {
@@ -400,6 +401,7 @@ mod tests {
     use super::{Data, BufferPool, Abort, Empty, Worker, Stealer};
 
     use cast;
+    use owned::Box;
     use rt::thread::Thread;
     use rand;
     use rand::Rng;
@@ -471,7 +473,7 @@ mod tests {
         t.join();
     }
 
-    fn stampede(mut w: Worker<~int>, s: Stealer<~int>,
+    fn stampede(mut w: Worker<Box<int>>, s: Stealer<Box<int>>,
                 nthreads: int, amt: uint) {
         for _ in range(0, amt) {
             w.push(box 20);
@@ -486,7 +488,7 @@ mod tests {
                     let mut s = s;
                     while (*unsafe_remaining).load(SeqCst) > 0 {
                         match s.steal() {
-                            Data(~20) => {
+                            Data(box 20) => {
                                 (*unsafe_remaining).fetch_sub(1, SeqCst);
                             }
                             Data(..) => fail!(),
@@ -499,7 +501,7 @@ mod tests {
 
         while remaining.load(SeqCst) > 0 {
             match w.pop() {
-                Some(~20) => { remaining.fetch_sub(1, SeqCst); }
+                Some(box 20) => { remaining.fetch_sub(1, SeqCst); }
                 Some(..) => fail!(),
                 None => {}
             }
@@ -512,7 +514,7 @@ mod tests {
 
     #[test]
     fn run_stampede() {
-        let mut pool = BufferPool::<~int>::new();
+        let mut pool = BufferPool::<Box<int>>::new();
         let (w, s) = pool.deque();
         stampede(w, s, 8, 10000);
     }
@@ -520,7 +522,7 @@ mod tests {
     #[test]
     fn many_stampede() {
         static AMT: uint = 4;
-        let mut pool = BufferPool::<~int>::new();
+        let mut pool = BufferPool::<Box<int>>::new();
         let threads = range(0, AMT).map(|_| {
             let (w, s) = pool.deque();
             Thread::start(proc() {
@@ -605,7 +607,8 @@ mod tests {
             let s = s.clone();
             let unique_box = box AtomicUint::new(0);
             let thread_box = unsafe {
-                *cast::transmute::<&~AtomicUint,**mut AtomicUint>(&unique_box)
+                *cast::transmute::<&Box<AtomicUint>,
+                                   **mut AtomicUint>(&unique_box)
             };
             (Thread::start(proc() {
                 unsafe {
diff --git a/src/libstd/sync/mpsc_queue.rs b/src/libstd/sync/mpsc_queue.rs
index 315e412446d..e05959e2591 100644
--- a/src/libstd/sync/mpsc_queue.rs
+++ b/src/libstd/sync/mpsc_queue.rs
@@ -42,6 +42,7 @@ use cast;
 use kinds::Send;
 use ops::Drop;
 use option::{Option, None, Some};
+use owned::Box;
 use ptr::RawPtr;
 use sync::atomics::{AtomicPtr, Release, Acquire, AcqRel, Relaxed};
 
@@ -120,7 +121,7 @@ impl<T: Send> Queue<T> {
                 assert!((*tail).value.is_none());
                 assert!((*next).value.is_some());
                 let ret = (*next).value.take_unwrap();
-                let _: ~Node<T> = cast::transmute(tail);
+                let _: Box<Node<T>> = cast::transmute(tail);
                 return Data(ret);
             }
 
@@ -145,7 +146,7 @@ impl<T: Send> Drop for Queue<T> {
             let mut cur = self.tail;
             while !cur.is_null() {
                 let next = (*cur).next.load(Relaxed);
-                let _: ~Node<T> = cast::transmute(cur);
+                let _: Box<Node<T>> = cast::transmute(cur);
                 cur = next;
             }
         }
diff --git a/src/libstd/sync/spsc_queue.rs b/src/libstd/sync/spsc_queue.rs
index f155bdca446..7854a0e168e 100644
--- a/src/libstd/sync/spsc_queue.rs
+++ b/src/libstd/sync/spsc_queue.rs
@@ -37,6 +37,7 @@ use cast;
 use kinds::Send;
 use ops::Drop;
 use option::{Some, None, Option};
+use owned::Box;
 use ptr::RawPtr;
 use sync::atomics::{AtomicPtr, Relaxed, AtomicUint, Acquire, Release};
 
@@ -187,7 +188,7 @@ impl<T: Send> Queue<T> {
                     (*self.tail_prev.load(Relaxed)).next.store(next, Relaxed);
                     // We have successfully erased all references to 'tail', so
                     // now we can safely drop it.
-                    let _: ~Node<T> = cast::transmute(tail);
+                    let _: Box<Node<T>> = cast::transmute(tail);
                 }
             }
             return ret;
@@ -215,7 +216,7 @@ impl<T: Send> Drop for Queue<T> {
             let mut cur = self.first;
             while !cur.is_null() {
                 let next = (*cur).next.load(Relaxed);
-                let _n: ~Node<T> = cast::transmute(cur);
+                let _n: Box<Node<T>> = cast::transmute(cur);
                 cur = next;
             }
         }