about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-08-04 00:40:10 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-04 15:11:56 -0700
commit3f4c6cead67cedea5042d5ba84fb490dfee5462a (patch)
treee5100795a3925888510286ff5769b6043a510a41
parent2f8346b949169bd0f4b8fe0630eb4bc49ae35f11 (diff)
downloadrust-3f4c6cead67cedea5042d5ba84fb490dfee5462a.tar.gz
rust-3f4c6cead67cedea5042d5ba84fb490dfee5462a.zip
Remove old tests and code for `select`
Not compatible with newsched
-rw-r--r--src/libextra/comm.rs9
-rw-r--r--src/libstd/comm.rs110
-rw-r--r--src/libstd/pipes.rs44
-rw-r--r--src/test/run-pass/issue-3176.rs39
4 files changed, 3 insertions, 199 deletions
diff --git a/src/libextra/comm.rs b/src/libextra/comm.rs
index 44581efc6f0..776e25cac89 100644
--- a/src/libextra/comm.rs
+++ b/src/libextra/comm.rs
@@ -18,9 +18,8 @@ Higher level communication abstractions.
 
 
 use std::comm::{GenericChan, GenericSmartChan, GenericPort};
-use std::comm::{Chan, Port, Selectable, Peekable};
+use std::comm::{Chan, Port, Peekable};
 use std::comm;
-use std::pipes;
 
 /// An extension of `pipes::stream` that allows both sending and receiving.
 pub struct DuplexStream<T, U> {
@@ -75,12 +74,6 @@ impl<T:Send,U:Send> Peekable<U> for DuplexStream<T, U> {
     }
 }
 
-impl<T:Send,U:Send> Selectable for DuplexStream<T, U> {
-    fn header(&mut self) -> *mut pipes::PacketHeader {
-        self.port.header()
-    }
-}
-
 /// Creates a bidirectional stream.
 pub fn DuplexStream<T:Send,U:Send>()
     -> (DuplexStream<T, U>, DuplexStream<U, T>)
diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs
index a0731dc3494..4356f1143da 100644
--- a/src/libstd/comm.rs
+++ b/src/libstd/comm.rs
@@ -14,7 +14,6 @@ Message passing
 
 #[allow(missing_doc)];
 
-use cast::transmute;
 use either::{Either, Left, Right};
 use kinds::Send;
 use option::{Option, Some};
@@ -23,12 +22,6 @@ pub use rt::comm::SendDeferred;
 use rtcomm = rt::comm;
 use rt;
 
-use pipes::{wait_many, PacketHeader};
-
-// FIXME #5160: Making this public exposes some plumbing from
-// pipes. Needs some refactoring
-pub use pipes::Selectable;
-
 /// A trait for things that can send multiple messages.
 pub trait GenericChan<T> {
     /// Sends a message.
@@ -146,15 +139,6 @@ impl<T: Send> Peekable<T> for Port<T> {
     }
 }
 
-impl<T: Send> Selectable for Port<T> {
-    fn header(&mut self) -> *mut PacketHeader {
-        match self.inner {
-            Left(ref mut port) => port.header(),
-            Right(_) => fail!("can't select on newsched ports")
-        }
-    }
-}
-
 /// A channel that can be shared between many senders.
 pub struct SharedChan<T> {
     inner: Either<Exclusive<pipesy::Chan<T>>, rtcomm::SharedChan<T>>
@@ -318,8 +302,8 @@ mod pipesy {
 
     use kinds::Send;
     use option::{Option, Some, None};
-    use pipes::{recv, try_recv, peek, PacketHeader};
-    use super::{GenericChan, GenericSmartChan, GenericPort, Peekable, Selectable};
+    use pipes::{recv, try_recv, peek};
+    use super::{GenericChan, GenericSmartChan, GenericPort, Peekable};
     use cast::transmute_mut;
 
     /*proto! oneshot (
@@ -651,80 +635,6 @@ mod pipesy {
         }
     }
 
-    impl<T: Send> Selectable for Port<T> {
-        fn header(&mut self) -> *mut PacketHeader {
-            match self.endp {
-                Some(ref mut endp) => endp.header(),
-                None => fail!("peeking empty stream")
-            }
-    }
-}
-
-}
-
-/// Returns the index of an endpoint that is ready to receive.
-pub fn selecti<T: Selectable>(endpoints: &mut [T]) -> uint {
-    wait_many(endpoints)
-}
-
-/// Returns 0 or 1 depending on which endpoint is ready to receive
-pub fn select2i<A:Selectable, B:Selectable>(a: &mut A, b: &mut B)
-                                            -> Either<(), ()> {
-    let mut endpoints = [ a.header(), b.header() ];
-    match wait_many(endpoints) {
-        0 => Left(()),
-        1 => Right(()),
-        _ => fail!("wait returned unexpected index"),
-    }
-}
-
-/// Receive a message from one of two endpoints.
-pub trait Select2<T: Send, U: Send> {
-    /// Receive a message or return `None` if a connection closes.
-    fn try_select(&mut self) -> Either<Option<T>, Option<U>>;
-    /// Receive a message or fail if a connection closes.
-    fn select(&mut self) -> Either<T, U>;
-}
-
-impl<T:Send,
-     U:Send,
-     Left:Selectable + GenericPort<T>,
-     Right:Selectable + GenericPort<U>>
-     Select2<T, U>
-     for (Left, Right) {
-    fn select(&mut self) -> Either<T, U> {
-        // XXX: Bad borrow check workaround.
-        unsafe {
-            let this: &(Left, Right) = transmute(self);
-            match *this {
-                (ref lp, ref rp) => {
-                    let lp: &mut Left = transmute(lp);
-                    let rp: &mut Right = transmute(rp);
-                    match select2i(lp, rp) {
-                        Left(()) => Left(lp.recv()),
-                        Right(()) => Right(rp.recv()),
-                    }
-                }
-            }
-        }
-    }
-
-    fn try_select(&mut self) -> Either<Option<T>, Option<U>> {
-        // XXX: Bad borrow check workaround.
-        unsafe {
-            let this: &(Left, Right) = transmute(self);
-            match *this {
-                (ref lp, ref rp) => {
-                    let lp: &mut Left = transmute(lp);
-                    let rp: &mut Right = transmute(rp);
-                    match select2i(lp, rp) {
-                        Left(()) => Left (lp.try_recv()),
-                        Right(()) => Right(rp.try_recv()),
-                    }
-                }
-            }
-        }
-    }
 }
 
 #[cfg(test)]
@@ -733,22 +643,6 @@ mod test {
     use super::{Chan, Port, oneshot, stream};
 
     #[test]
-    fn test_select2() {
-        let (p1, c1) = stream();
-        let (p2, c2) = stream();
-
-        c1.send(~"abc");
-
-        let mut tuple = (p1, p2);
-        match tuple.select() {
-            Right(_) => fail!(),
-            _ => (),
-        }
-
-        c2.send(123);
-    }
-
-    #[test]
     fn test_oneshot() {
         let (p, c) = oneshot();
 
diff --git a/src/libstd/pipes.rs b/src/libstd/pipes.rs
index 1fd534825a5..78f937e058a 100644
--- a/src/libstd/pipes.rs
+++ b/src/libstd/pipes.rs
@@ -868,47 +868,3 @@ pub mod rt {
     pub fn make_some<T>(val: T) -> Option<T> { Some(val) }
     pub fn make_none<T>() -> Option<T> { None }
 }
-
-#[cfg(test)]
-mod test {
-    use either::Right;
-    use comm::{Chan, Port, oneshot, recv_one, stream, Select2,
-               GenericChan, Peekable};
-
-    #[test]
-    fn test_select2() {
-        let (p1, c1) = stream();
-        let (p2, c2) = stream();
-
-        c1.send(~"abc");
-
-        let mut tuple = (p1, p2);
-        match tuple.select() {
-            Right(_) => fail!(),
-            _ => (),
-        }
-
-        c2.send(123);
-    }
-
-    #[test]
-    fn test_oneshot() {
-        let (p, c) = oneshot();
-
-        c.send(());
-
-        recv_one(p)
-    }
-
-    #[test]
-    fn test_peek_terminated() {
-        let (port, chan): (Port<int>, Chan<int>) = stream();
-
-        {
-            // Destroy the channel
-            let _chan = chan;
-        }
-
-        assert!(!port.peek());
-    }
-}
diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs
deleted file mode 100644
index df242ee3d30..00000000000
--- a/src/test/run-pass/issue-3176.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-fast
-// xfail-win32 #7999
-
-use std::comm::{Select2, Selectable};
-use std::comm;
-use std::task;
-
-pub fn main() {
-    let (p,c) = comm::stream();
-    do task::try || {
-        let (p2,c2) = comm::stream();
-        do task::spawn || {
-            p2.recv();
-            error!("sibling fails");
-            fail!();
-        }
-        let (p3,c3) = comm::stream();
-        c.send(c3);
-        c2.send(());
-        error!("child blocks");
-        let (p, c) = comm::stream();
-        let mut tuple = (p, p3);
-        tuple.select();
-        c.send(());
-    };
-    error!("parent tries");
-    assert!(!p.recv().try_send(()));
-    error!("all done!");
-}