Skip to content

Commit 3f4c6ce

Browse files
committed
Remove old tests and code for select
Not compatible with newsched
1 parent 2f8346b commit 3f4c6ce

File tree

4 files changed

+3
-199
lines changed

4 files changed

+3
-199
lines changed

src/libextra/comm.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ Higher level communication abstractions.
1818

1919

2020
use std::comm::{GenericChan, GenericSmartChan, GenericPort};
21-
use std::comm::{Chan, Port, Selectable, Peekable};
21+
use std::comm::{Chan, Port, Peekable};
2222
use std::comm;
23-
use std::pipes;
2423

2524
/// An extension of `pipes::stream` that allows both sending and receiving.
2625
pub struct DuplexStream<T, U> {
@@ -75,12 +74,6 @@ impl<T:Send,U:Send> Peekable<U> for DuplexStream<T, U> {
7574
}
7675
}
7776

78-
impl<T:Send,U:Send> Selectable for DuplexStream<T, U> {
79-
fn header(&mut self) -> *mut pipes::PacketHeader {
80-
self.port.header()
81-
}
82-
}
83-
8477
/// Creates a bidirectional stream.
8578
pub fn DuplexStream<T:Send,U:Send>()
8679
-> (DuplexStream<T, U>, DuplexStream<U, T>)

src/libstd/comm.rs

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Message passing
1414

1515
#[allow(missing_doc)];
1616

17-
use cast::transmute;
1817
use either::{Either, Left, Right};
1918
use kinds::Send;
2019
use option::{Option, Some};
@@ -23,12 +22,6 @@ pub use rt::comm::SendDeferred;
2322
use rtcomm = rt::comm;
2423
use rt;
2524

26-
use pipes::{wait_many, PacketHeader};
27-
28-
// FIXME #5160: Making this public exposes some plumbing from
29-
// pipes. Needs some refactoring
30-
pub use pipes::Selectable;
31-
3225
/// A trait for things that can send multiple messages.
3326
pub trait GenericChan<T> {
3427
/// Sends a message.
@@ -146,15 +139,6 @@ impl<T: Send> Peekable<T> for Port<T> {
146139
}
147140
}
148141

149-
impl<T: Send> Selectable for Port<T> {
150-
fn header(&mut self) -> *mut PacketHeader {
151-
match self.inner {
152-
Left(ref mut port) => port.header(),
153-
Right(_) => fail!("can't select on newsched ports")
154-
}
155-
}
156-
}
157-
158142
/// A channel that can be shared between many senders.
159143
pub struct SharedChan<T> {
160144
inner: Either<Exclusive<pipesy::Chan<T>>, rtcomm::SharedChan<T>>
@@ -318,8 +302,8 @@ mod pipesy {
318302

319303
use kinds::Send;
320304
use option::{Option, Some, None};
321-
use pipes::{recv, try_recv, peek, PacketHeader};
322-
use super::{GenericChan, GenericSmartChan, GenericPort, Peekable, Selectable};
305+
use pipes::{recv, try_recv, peek};
306+
use super::{GenericChan, GenericSmartChan, GenericPort, Peekable};
323307
use cast::transmute_mut;
324308

325309
/*proto! oneshot (
@@ -651,103 +635,13 @@ mod pipesy {
651635
}
652636
}
653637

654-
impl<T: Send> Selectable for Port<T> {
655-
fn header(&mut self) -> *mut PacketHeader {
656-
match self.endp {
657-
Some(ref mut endp) => endp.header(),
658-
None => fail!("peeking empty stream")
659-
}
660-
}
661-
}
662-
663-
}
664-
665-
/// Returns the index of an endpoint that is ready to receive.
666-
pub fn selecti<T: Selectable>(endpoints: &mut [T]) -> uint {
667-
wait_many(endpoints)
668-
}
669-
670-
/// Returns 0 or 1 depending on which endpoint is ready to receive
671-
pub fn select2i<A:Selectable, B:Selectable>(a: &mut A, b: &mut B)
672-
-> Either<(), ()> {
673-
let mut endpoints = [ a.header(), b.header() ];
674-
match wait_many(endpoints) {
675-
0 => Left(()),
676-
1 => Right(()),
677-
_ => fail!("wait returned unexpected index"),
678-
}
679-
}
680-
681-
/// Receive a message from one of two endpoints.
682-
pub trait Select2<T: Send, U: Send> {
683-
/// Receive a message or return `None` if a connection closes.
684-
fn try_select(&mut self) -> Either<Option<T>, Option<U>>;
685-
/// Receive a message or fail if a connection closes.
686-
fn select(&mut self) -> Either<T, U>;
687-
}
688-
689-
impl<T:Send,
690-
U:Send,
691-
Left:Selectable + GenericPort<T>,
692-
Right:Selectable + GenericPort<U>>
693-
Select2<T, U>
694-
for (Left, Right) {
695-
fn select(&mut self) -> Either<T, U> {
696-
// XXX: Bad borrow check workaround.
697-
unsafe {
698-
let this: &(Left, Right) = transmute(self);
699-
match *this {
700-
(ref lp, ref rp) => {
701-
let lp: &mut Left = transmute(lp);
702-
let rp: &mut Right = transmute(rp);
703-
match select2i(lp, rp) {
704-
Left(()) => Left(lp.recv()),
705-
Right(()) => Right(rp.recv()),
706-
}
707-
}
708-
}
709-
}
710-
}
711-
712-
fn try_select(&mut self) -> Either<Option<T>, Option<U>> {
713-
// XXX: Bad borrow check workaround.
714-
unsafe {
715-
let this: &(Left, Right) = transmute(self);
716-
match *this {
717-
(ref lp, ref rp) => {
718-
let lp: &mut Left = transmute(lp);
719-
let rp: &mut Right = transmute(rp);
720-
match select2i(lp, rp) {
721-
Left(()) => Left (lp.try_recv()),
722-
Right(()) => Right(rp.try_recv()),
723-
}
724-
}
725-
}
726-
}
727-
}
728638
}
729639

730640
#[cfg(test)]
731641
mod test {
732642
use either::Right;
733643
use super::{Chan, Port, oneshot, stream};
734644

735-
#[test]
736-
fn test_select2() {
737-
let (p1, c1) = stream();
738-
let (p2, c2) = stream();
739-
740-
c1.send(~"abc");
741-
742-
let mut tuple = (p1, p2);
743-
match tuple.select() {
744-
Right(_) => fail!(),
745-
_ => (),
746-
}
747-
748-
c2.send(123);
749-
}
750-
751645
#[test]
752646
fn test_oneshot() {
753647
let (p, c) = oneshot();

src/libstd/pipes.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -868,47 +868,3 @@ pub mod rt {
868868
pub fn make_some<T>(val: T) -> Option<T> { Some(val) }
869869
pub fn make_none<T>() -> Option<T> { None }
870870
}
871-
872-
#[cfg(test)]
873-
mod test {
874-
use either::Right;
875-
use comm::{Chan, Port, oneshot, recv_one, stream, Select2,
876-
GenericChan, Peekable};
877-
878-
#[test]
879-
fn test_select2() {
880-
let (p1, c1) = stream();
881-
let (p2, c2) = stream();
882-
883-
c1.send(~"abc");
884-
885-
let mut tuple = (p1, p2);
886-
match tuple.select() {
887-
Right(_) => fail!(),
888-
_ => (),
889-
}
890-
891-
c2.send(123);
892-
}
893-
894-
#[test]
895-
fn test_oneshot() {
896-
let (p, c) = oneshot();
897-
898-
c.send(());
899-
900-
recv_one(p)
901-
}
902-
903-
#[test]
904-
fn test_peek_terminated() {
905-
let (port, chan): (Port<int>, Chan<int>) = stream();
906-
907-
{
908-
// Destroy the channel
909-
let _chan = chan;
910-
}
911-
912-
assert!(!port.peek());
913-
}
914-
}

src/test/run-pass/issue-3176.rs

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)