about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-04-09 11:43:33 +1000
committerAlex Crichton <alex@alexcrichton.com>2014-04-10 15:21:58 -0700
commita65411e4f7b5df78e34dcaf8061d4641f4b56412 (patch)
tree3215d5cac2cd39ada18f21d8746dc95765d71b02 /src/libstd/sync
parent342e8b59be97c28be38d54bec10e511ae17da129 (diff)
downloadrust-a65411e4f7b5df78e34dcaf8061d4641f4b56412.tar.gz
rust-a65411e4f7b5df78e34dcaf8061d4641f4b56412.zip
std,serialize: remove some internal uses of ~[].
These are all private uses of ~[], so can easily & non-controversially
be replaced with Vec.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/deque.rs16
-rw-r--r--src/libstd/sync/mpmc_bounded_queue.rs12
2 files changed, 14 insertions, 14 deletions
diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs
index d01c89878de..8beadce2160 100644
--- a/src/libstd/sync/deque.rs
+++ b/src/libstd/sync/deque.rs
@@ -62,6 +62,7 @@ use sync::arc::UnsafeArc;
 use sync::atomics::{AtomicInt, AtomicPtr, SeqCst};
 use unstable::sync::Exclusive;
 use slice::{OwnedVector, ImmutableVector};
+use vec::Vec;
 
 // Once the queue is less than 1/K full, then it will be downsized. Note that
 // the deque requires that this number be less than 2.
@@ -116,14 +117,14 @@ 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<~[~Buffer<T>]>,
+    pool: Exclusive<Vec<~Buffer<T>>>,
 }
 
 /// An internal buffer used by the chase-lev deque. This structure is actually
 /// implemented as a circular buffer, and is used as the intermediate storage of
 /// the data in the deque.
 ///
-/// This type is implemented with *T instead of ~[T] for two reasons:
+/// This type is implemented with *T instead of Vec<T> for two reasons:
 ///
 ///   1. There is nothing safe about using this buffer. This easily allows the
 ///      same value to be read twice in to rust, and there is nothing to
@@ -132,7 +133,7 @@ pub struct BufferPool<T> {
 ///      destructors for values in this buffer (on drop) because the bounds
 ///      are defined by the deque it's owned by.
 ///
-///   2. We can certainly avoid bounds checks using *T instead of ~[T], although
+///   2. We can certainly avoid bounds checks using *T instead of Vec<T>, although
 ///      LLVM is probably pretty good at doing this already.
 struct Buffer<T> {
     storage: *T,
@@ -143,7 +144,7 @@ impl<T: Send> BufferPool<T> {
     /// Allocates a new buffer pool which in turn can be used to allocate new
     /// deques.
     pub fn new() -> BufferPool<T> {
-        BufferPool { pool: Exclusive::new(~[]) }
+        BufferPool { pool: Exclusive::new(vec!()) }
     }
 
     /// Allocates a new work-stealing deque which will send/receiving memory to
@@ -494,7 +495,7 @@ mod tests {
                     }
                 }
             })
-        }).collect::<~[Thread<()>]>();
+        }).collect::<Vec<Thread<()>>>();
 
         while remaining.load(SeqCst) > 0 {
             match w.pop() {
@@ -525,7 +526,7 @@ mod tests {
             Thread::start(proc() {
                 stampede(w, s, 4, 10000);
             })
-        }).collect::<~[Thread<()>]>();
+        }).collect::<Vec<Thread<()>>>();
 
         for thread in threads.move_iter() {
             thread.join();
@@ -556,7 +557,7 @@ mod tests {
                     }
                 }
             })
-        }).collect::<~[Thread<()>]>();
+        }).collect::<Vec<Thread<()>>>();
 
         let mut rng = rand::task_rng();
         let mut expected = 0;
@@ -658,4 +659,3 @@ mod tests {
         }
     }
 }
-
diff --git a/src/libstd/sync/mpmc_bounded_queue.rs b/src/libstd/sync/mpmc_bounded_queue.rs
index 12c05c0d61c..b392cc8ff9a 100644
--- a/src/libstd/sync/mpmc_bounded_queue.rs
+++ b/src/libstd/sync/mpmc_bounded_queue.rs
@@ -35,7 +35,7 @@ use num::next_power_of_two;
 use option::{Option, Some, None};
 use sync::arc::UnsafeArc;
 use sync::atomics::{AtomicUint,Relaxed,Release,Acquire};
-use slice;
+use vec::Vec;
 
 struct Node<T> {
     sequence: AtomicUint,
@@ -44,7 +44,7 @@ struct Node<T> {
 
 struct State<T> {
     pad0: [u8, ..64],
-    buffer: ~[Node<T>],
+    buffer: Vec<Node<T>>,
     mask: uint,
     pad1: [u8, ..64],
     enqueue_pos: AtomicUint,
@@ -69,7 +69,7 @@ impl<T: Send> State<T> {
         } else {
             capacity
         };
-        let buffer = slice::from_fn(capacity, |i| {
+        let buffer = Vec::from_fn(capacity, |i| {
             Node { sequence:AtomicUint::new(i), value: None }
         });
         State{
@@ -88,7 +88,7 @@ impl<T: Send> State<T> {
         let mask = self.mask;
         let mut pos = self.enqueue_pos.load(Relaxed);
         loop {
-            let node = &mut self.buffer[pos & mask];
+            let node = self.buffer.get_mut(pos & mask);
             let seq = node.sequence.load(Acquire);
             let diff: int = seq as int - pos as int;
 
@@ -114,7 +114,7 @@ impl<T: Send> State<T> {
         let mask = self.mask;
         let mut pos = self.dequeue_pos.load(Relaxed);
         loop {
-            let node = &mut self.buffer[pos & mask];
+            let node = self.buffer.get_mut(pos & mask);
             let seq = node.sequence.load(Acquire);
             let diff: int = seq as int - (pos + 1) as int;
             if diff == 0 {
@@ -186,7 +186,7 @@ mod tests {
             });
         }
 
-        let mut completion_rxs = ~[];
+        let mut completion_rxs = vec![];
         for _ in range(0, nthreads) {
             let (tx, rx) = channel();
             completion_rxs.push(rx);