diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index d16f0f3a330..618d49dbaf5 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -318,10 +318,22 @@ fn select2( } } -fn selecti(endpoints: &[&recv_packet]) -> uint { +trait selectable { + pure fn header() -> *packet_header; +} + +fn selecti(endpoints: &[T]) -> uint { wait_many(endpoints.map(|p| p.header())) } +fn select2i(a: A, b: B) -> either<(), ()> { + alt wait_many([a.header(), b.header()]/_) { + 0 { left(()) } + 1 { right(()) } + _ { fail "wait returned unexpected index" } + } +} + #[doc = "Waits on a set of endpoints. Returns a message, its index, and a list of the remaining endpoints."] fn select(+endpoints: ~[recv_packet]) @@ -552,7 +564,7 @@ class port_set { } } -impl private_methods/& for pipes::port { +impl of selectable for pipes::port { pure fn header() -> *pipes::packet_header unchecked { alt self.endp { some(endp) {