about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2014-04-25 01:08:02 -0700
committerBrian Anderson <banderson@mozilla.com>2014-05-02 23:00:58 -0700
commita5be12ce7e88c1d28de1c98215991127d1e765f0 (patch)
tree30f160f43a354c79a6795c638c3302d234ec0b52 /src/libstd/sync
parenta67307e2a56b0d6bc57c3dc18f58e79744e98434 (diff)
downloadrust-a5be12ce7e88c1d28de1c98215991127d1e765f0.tar.gz
rust-a5be12ce7e88c1d28de1c98215991127d1e765f0.zip
Replace most ~exprs with 'box'. #11779
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/arc.rs4
-rw-r--r--src/libstd/sync/atomics.rs26
-rw-r--r--src/libstd/sync/deque.rs8
-rw-r--r--src/libstd/sync/mpsc_queue.rs6
-rw-r--r--src/libstd/sync/spsc_queue.rs6
5 files changed, 25 insertions, 25 deletions
diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs
index 8d6d1c222cf..0cf975a4c1c 100644
--- a/src/libstd/sync/arc.rs
+++ b/src/libstd/sync/arc.rs
@@ -45,7 +45,7 @@ struct ArcData<T> {
 }
 
 unsafe fn new_inner<T: Send>(data: T, refcount: uint) -> *mut ArcData<T> {
-    let data = ~ArcData {
+    let data = box ArcData {
                     count: AtomicUint::new(refcount),
                     data: Unsafe::new(data)
                  };
@@ -71,7 +71,7 @@ impl<T: Send> UnsafeArc<T> {
     pub fn newN(data: T, num_handles: uint) -> ~[UnsafeArc<T>] {
         unsafe {
             if num_handles == 0 {
-                ~[] // need to free data here
+                box [] // need to free data here
             } else {
                 let ptr = new_inner(data, num_handles);
                 let v = Vec::from_fn(num_handles, |_| UnsafeArc { data: ptr });
diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs
index e6b71b502c2..a3c1c33f77c 100644
--- a/src/libstd/sync/atomics.rs
+++ b/src/libstd/sync/atomics.rs
@@ -894,36 +894,36 @@ mod test {
 
     #[test]
     fn option_swap() {
-        let p = AtomicOption::new(~1);
-        let a = ~2;
+        let p = AtomicOption::new(box 1);
+        let a = box 2;
 
         let b = p.swap(a, SeqCst);
 
-        assert_eq!(b, Some(~1));
-        assert_eq!(p.take(SeqCst), Some(~2));
+        assert_eq!(b, Some(box 1));
+        assert_eq!(p.take(SeqCst), Some(box 2));
     }
 
     #[test]
     fn option_take() {
-        let p = AtomicOption::new(~1);
+        let p = AtomicOption::new(box 1);
 
-        assert_eq!(p.take(SeqCst), Some(~1));
+        assert_eq!(p.take(SeqCst), Some(box 1));
         assert_eq!(p.take(SeqCst), None);
 
-        let p2 = ~2;
+        let p2 = box 2;
         p.swap(p2, SeqCst);
 
-        assert_eq!(p.take(SeqCst), Some(~2));
+        assert_eq!(p.take(SeqCst), Some(box 2));
     }
 
     #[test]
     fn option_fill() {
-        let p = AtomicOption::new(~1);
-        assert!(p.fill(~2, SeqCst).is_some()); // should fail; shouldn't leak!
-        assert_eq!(p.take(SeqCst), Some(~1));
+        let p = AtomicOption::new(box 1);
+        assert!(p.fill(box 2, SeqCst).is_some()); // should fail; shouldn't leak!
+        assert_eq!(p.take(SeqCst), Some(box 1));
 
-        assert!(p.fill(~2, SeqCst).is_none()); // shouldn't fail
-        assert_eq!(p.take(SeqCst), Some(~2));
+        assert!(p.fill(box 2, SeqCst).is_none()); // shouldn't fail
+        assert_eq!(p.take(SeqCst), Some(box 2));
     }
 
     #[test]
diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs
index 97239707d32..22ed66b708b 100644
--- a/src/libstd/sync/deque.rs
+++ b/src/libstd/sync/deque.rs
@@ -159,7 +159,7 @@ impl<T: Send> BufferPool<T> {
             self.pool.with(|pool| {
                 match pool.iter().position(|x| x.size() >= (1 << bits)) {
                     Some(i) => pool.remove(i).unwrap(),
-                    None => ~Buffer::new(bits)
+                    None => box Buffer::new(bits)
                 }
             })
         }
@@ -314,7 +314,7 @@ impl<T: Send> Deque<T> {
     // continue to be read after we flag this buffer for reclamation.
     unsafe fn swap_buffer(&mut self, b: int, old: *mut Buffer<T>,
                           buf: Buffer<T>) -> *mut Buffer<T> {
-        let newbuf: *mut Buffer<T> = cast::transmute(~buf);
+        let newbuf: *mut Buffer<T> = cast::transmute(box buf);
         self.array.store(newbuf, SeqCst);
         let ss = (*newbuf).size();
         self.bottom.store(b + ss, SeqCst);
@@ -474,7 +474,7 @@ mod tests {
     fn stampede(mut w: Worker<~int>, s: Stealer<~int>,
                 nthreads: int, amt: uint) {
         for _ in range(0, amt) {
-            w.push(~20);
+            w.push(box 20);
         }
         let mut remaining = AtomicUint::new(amt);
         let unsafe_remaining: *mut AtomicUint = &mut remaining;
@@ -603,7 +603,7 @@ mod tests {
 
         let (threads, hits) = slice::unzip(range(0, NTHREADS).map(|_| {
             let s = s.clone();
-            let unique_box = ~AtomicUint::new(0);
+            let unique_box = box AtomicUint::new(0);
             let thread_box = unsafe {
                 *cast::transmute::<&~AtomicUint,**mut AtomicUint>(&unique_box)
             };
diff --git a/src/libstd/sync/mpsc_queue.rs b/src/libstd/sync/mpsc_queue.rs
index 142a6239df6..315e412446d 100644
--- a/src/libstd/sync/mpsc_queue.rs
+++ b/src/libstd/sync/mpsc_queue.rs
@@ -73,7 +73,7 @@ pub struct Queue<T> {
 
 impl<T> Node<T> {
     unsafe fn new(v: Option<T>) -> *mut Node<T> {
-        cast::transmute(~Node {
+        cast::transmute(box Node {
             next: AtomicPtr::new(0 as *mut Node<T>),
             value: v,
         })
@@ -163,8 +163,8 @@ mod tests {
     #[test]
     fn test_full() {
         let mut q = Queue::new();
-        q.push(~1);
-        q.push(~2);
+        q.push(box 1);
+        q.push(box 2);
     }
 
     #[test]
diff --git a/src/libstd/sync/spsc_queue.rs b/src/libstd/sync/spsc_queue.rs
index 4e043ecf171..f155bdca446 100644
--- a/src/libstd/sync/spsc_queue.rs
+++ b/src/libstd/sync/spsc_queue.rs
@@ -73,7 +73,7 @@ pub struct Queue<T> {
 impl<T: Send> Node<T> {
     fn new() -> *mut Node<T> {
         unsafe {
-            cast::transmute(~Node {
+            cast::transmute(box Node {
                 value: None,
                 next: AtomicPtr::new(0 as *mut Node<T>),
             })
@@ -247,8 +247,8 @@ mod test {
     #[test]
     fn drop_full() {
         let mut q = Queue::new(0);
-        q.push(~1);
-        q.push(~2);
+        q.push(box 1);
+        q.push(box 2);
     }
 
     #[test]