Skip to content

Commit 25dd050

Browse files
committed
---
yaml --- r: 35453 b: refs/heads/master c: 1b48101 h: refs/heads/master i: 35451: 4352bbc v: v3
1 parent b452e81 commit 25dd050

File tree

5 files changed

+44
-28
lines changed

5 files changed

+44
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 86f7eb344665cba48089ad63c891cd7834c38499
2+
refs/heads/master: 1b481017acfc51063d6ab69de6e310634ceb6804
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/libcore/pipes.rs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ pub pure fn peek<T: Send, Tb: Send>(p: &RecvPacketBuffered<T, Tb>) -> bool {
527527
}
528528
}
529529

530-
impl<T: Send, Tb: Send> RecvPacketBuffered<T, Tb> {
530+
impl<T: Send, Tb: Send> RecvPacketBuffered<T, Tb>: Peekable<T> {
531531
pure fn peek() -> bool {
532532
peek(&self)
533533
}
@@ -928,32 +928,32 @@ proto! streamp (
928928
)
929929

930930
/// A trait for things that can send multiple messages.
931-
pub trait Channel<T: Send> {
932-
// It'd be nice to call this send, but it'd conflict with the
933-
// built in send kind.
934-
931+
pub trait GenericChan<T> {
935932
/// Sends a message.
936933
fn send(x: T);
934+
}
937935

936+
/// Things that can send multiple messages and can detect when the receiver
937+
/// is closed
938+
pub trait GenericSmartChan<T> {
938939
/// Sends a message, or report if the receiver has closed the connection.
939940
fn try_send(x: T) -> bool;
940941
}
941942

942943
/// A trait for things that can receive multiple messages.
943-
pub trait Recv<T: Send> {
944+
pub trait GenericPort<T> {
944945
/// Receives a message, or fails if the connection closes.
945946
fn recv() -> T;
946947

947-
/** Receives a message if one is available, or returns `none` if
948-
the connection is closed.
949-
948+
/** Receives a message, or returns `none` if
949+
the connection is closed or closes.
950950
*/
951951
fn try_recv() -> Option<T>;
952+
}
952953

953-
/** Returns true if a message is available or the connection is
954-
closed.
955-
956-
*/
954+
/// Ports that can `peek`
955+
pub trait Peekable<T> {
956+
/// Returns true if a message is available
957957
pure fn peek() -> bool;
958958
}
959959

@@ -984,13 +984,16 @@ pub fn stream<T:Send>() -> (Chan<T>, Port<T>) {
984984
(Chan_({ mut endp: Some(move c) }), Port_({ mut endp: Some(move s) }))
985985
}
986986

987-
impl<T: Send> Chan<T>: Channel<T> {
987+
impl<T: Send> Chan<T>: GenericChan<T> {
988988
fn send(x: T) {
989989
let mut endp = None;
990990
endp <-> self.endp;
991991
self.endp = Some(
992992
streamp::client::data(unwrap(move endp), move x))
993993
}
994+
}
995+
996+
impl<T: Send> Chan<T>: GenericSmartChan<T> {
994997

995998
fn try_send(x: T) -> bool {
996999
let mut endp = None;
@@ -1005,7 +1008,7 @@ impl<T: Send> Chan<T>: Channel<T> {
10051008
}
10061009
}
10071010

1008-
impl<T: Send> Port<T>: Recv<T> {
1011+
impl<T: Send> Port<T>: GenericPort<T> {
10091012
fn recv() -> T {
10101013
let mut endp = None;
10111014
endp <-> self.endp;
@@ -1025,7 +1028,9 @@ impl<T: Send> Port<T>: Recv<T> {
10251028
None => None
10261029
}
10271030
}
1031+
}
10281032

1033+
impl<T: Send> Port<T>: Peekable<T> {
10291034
pure fn peek() -> bool unsafe {
10301035
let mut endp = None;
10311036
endp <-> self.endp;
@@ -1071,7 +1076,7 @@ impl<T: Send> PortSet<T> {
10711076
}
10721077
}
10731078

1074-
impl<T: Send> PortSet<T> : Recv<T> {
1079+
impl<T: Send> PortSet<T> : GenericPort<T> {
10751080

10761081
fn try_recv() -> Option<T> {
10771082
let mut result = None;
@@ -1099,6 +1104,9 @@ impl<T: Send> PortSet<T> : Recv<T> {
10991104
option::unwrap_expect(self.try_recv(), "port_set: endpoints closed")
11001105
}
11011106

1107+
}
1108+
1109+
impl<T: Send> PortSet<T> : Peekable<T> {
11021110
pure fn peek() -> bool {
11031111
// It'd be nice to use self.port.each, but that version isn't
11041112
// pure.
@@ -1112,7 +1120,7 @@ impl<T: Send> PortSet<T> : Recv<T> {
11121120
/// A channel that can be shared between many senders.
11131121
pub type SharedChan<T: Send> = private::Exclusive<Chan<T>>;
11141122

1115-
impl<T: Send> SharedChan<T>: Channel<T> {
1123+
impl<T: Send> SharedChan<T>: GenericChan<T> {
11161124
fn send(x: T) {
11171125
let mut xx = Some(move x);
11181126
do self.with_imm |chan| {
@@ -1121,7 +1129,9 @@ impl<T: Send> SharedChan<T>: Channel<T> {
11211129
chan.send(option::unwrap(move x))
11221130
}
11231131
}
1132+
}
11241133

1134+
impl<T: Send> SharedChan<T>: GenericSmartChan<T> {
11251135
fn try_send(x: T) -> bool {
11261136
let mut xx = Some(move x);
11271137
do self.with_imm |chan| {
@@ -1145,7 +1155,9 @@ pub trait Select2<T: Send, U: Send> {
11451155
fn select() -> Either<T, U>;
11461156
}
11471157

1148-
impl<T: Send, U: Send, Left: Selectable Recv<T>, Right: Selectable Recv<U>>
1158+
impl<T: Send, U: Send,
1159+
Left: Selectable GenericPort<T>,
1160+
Right: Selectable GenericPort<U>>
11491161
(Left, Right): Select2<T, U> {
11501162

11511163
fn select() -> Either<T, U> {

trunk/src/libstd/comm.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,38 @@ Higher level communication abstractions.
1717
// NB: transitionary, de-mode-ing.
1818
#[forbid(deprecated_mode)];
1919

20-
use pipes::{Channel, Recv, Chan, Port, Selectable};
20+
use pipes::{GenericChan, GenericSmartChan, GenericPort,
21+
Chan, Port, Selectable, Peekable};
2122

2223
/// An extension of `pipes::stream` that allows both sending and receiving.
2324
pub struct DuplexStream<T: Send, U: Send> {
2425
priv chan: Chan<T>,
25-
priv port: Port <U>,
26+
priv port: Port<U>,
2627
}
2728

28-
impl<T: Send, U: Send> DuplexStream<T, U> : Channel<T> {
29+
impl<T: Send, U: Send> DuplexStream<T, U> : GenericChan<T> {
2930
fn send(x: T) {
3031
self.chan.send(move x)
3132
}
33+
}
3234

35+
impl<T: Send, U: Send> DuplexStream<T, U> : GenericSmartChan<T> {
3336
fn try_send(x: T) -> bool {
3437
self.chan.try_send(move x)
3538
}
3639
}
3740

38-
impl<T: Send, U: Send> DuplexStream<T, U> : Recv<U> {
41+
impl<T: Send, U: Send> DuplexStream<T, U> : GenericPort<U> {
3942
fn recv() -> U {
4043
self.port.recv()
4144
}
4245

4346
fn try_recv() -> Option<U> {
4447
self.port.try_recv()
4548
}
49+
}
4650

51+
impl<T: Send, U: Send> DuplexStream<T, U> : Peekable<U> {
4752
pure fn peek() -> bool {
4853
self.port.peek()
4954
}

trunk/src/libstd/ebml.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ pub mod reader {
157157

158158
pub fn doc_data(d: Doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start,
159159
d.end) }
160-
161160
pub fn with_doc_data<T>(d: Doc, f: fn(x: &[u8]) -> T) -> T {
162161
f(vec::view(*d.data, d.start, d.end))
163162
}
@@ -190,7 +189,7 @@ pub mod reader {
190189
pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 }
191190

192191

193-
struct Deserializer {
192+
pub struct Deserializer {
194193
priv mut parent: Doc,
195194
priv mut pos: uint,
196195
}
@@ -388,7 +387,7 @@ pub mod reader {
388387
pub mod writer {
389388

390389
// ebml writing
391-
struct Serializer {
390+
pub struct Serializer {
392391
writer: io::Writer,
393392
priv mut size_positions: ~[uint],
394393
}

trunk/src/libstd/net_tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern mod rustrt {
3535
* underlying libuv data structures when it goes out of scope. This is the
3636
* data structure that is used for read/write operations over a TCP stream.
3737
*/
38-
struct TcpSocket {
38+
pub struct TcpSocket {
3939
socket_data: @TcpSocketData,
4040
}
4141

@@ -59,7 +59,7 @@ pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
5959
* It is created with a call to `net::tcp::socket_buf()` and has impls that
6060
* satisfy both the `io::reader` and `io::writer` traits.
6161
*/
62-
struct TcpSocketBuf {
62+
pub struct TcpSocketBuf {
6363
data: @TcpBufferedSocketData,
6464
mut end_of_stream: bool,
6565
}

0 commit comments

Comments
 (0)