Skip to content

Commit

Permalink
Remove Queue::new.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Lockerman authored and Joshua Lockerman committed Oct 9, 2017
1 parent 41320fa commit bb7945e
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions src/libstd/sync/mpsc/spsc_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,6 @@ impl<T> Node<T> {
}
}

impl<T> Queue<T> {
#[cfg(all(test, not(target_os = "emscripten")))]
/// Creates a new queue.
///
/// This is unsafe as the type system doesn't enforce a single
/// consumer-producer relationship. It also allows the consumer to `pop`
/// items while there is a `peek` active due to all methods having a
/// non-mutable receiver.
///
/// # Arguments
///
/// * `bound` - This queue implementation is implemented with a linked
/// list, and this means that a push is always a malloc. In
/// order to amortize this cost, an internal cache of nodes is
/// maintained to prevent a malloc from always being
/// necessary. This bound is the limit on the size of the
/// cache (if desired). If the value is 0, then the cache has
/// no bound. Otherwise, the cache will never grow larger than
/// `bound` (although the queue itself could be much larger.
pub unsafe fn new(bound: usize) -> Queue<T> {
Self::with_additions(bound, (), ())
}
}

impl<T, ProducerAddition, ConsumerAddition> Queue<T, ProducerAddition, ConsumerAddition> {

/// Creates a new queue. With given additional elements in the producer and
Expand Down Expand Up @@ -275,7 +251,7 @@ mod tests {
#[test]
fn smoke() {
unsafe {
let queue = Queue::new(0);
let queue = Queue::with_additions(0, (), ());
queue.push(1);
queue.push(2);
assert_eq!(queue.pop(), Some(1));
Expand All @@ -292,7 +268,7 @@ mod tests {
#[test]
fn peek() {
unsafe {
let queue = Queue::new(0);
let queue = Queue::with_additions(0, (), ());
queue.push(vec![1]);

// Ensure the borrowchecker works
Expand All @@ -315,7 +291,7 @@ mod tests {
#[test]
fn drop_full() {
unsafe {
let q: Queue<Box<_>> = Queue::new(0);
let q: Queue<Box<_>> = Queue::with_additions(0, (), ());
q.push(box 1);
q.push(box 2);
}
Expand All @@ -324,7 +300,7 @@ mod tests {
#[test]
fn smoke_bound() {
unsafe {
let q = Queue::new(0);
let q = Queue::with_additions(0, (), ());
q.push(1);
q.push(2);
assert_eq!(q.pop(), Some(1));
Expand All @@ -346,7 +322,7 @@ mod tests {
}

unsafe fn stress_bound(bound: usize) {
let q = Arc::new(Queue::new(bound));
let q = Arc::new(Queue::with_additions(bound, (), ()));

let (tx, rx) = channel();
let q2 = q.clone();
Expand Down

0 comments on commit bb7945e

Please sign in to comment.