Skip to content

Commit 40920c0

Browse files
committed
---
yaml --- r: 23178 b: refs/heads/master c: 2ac2883 h: refs/heads/master v: v3
1 parent d522bd6 commit 40920c0

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
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: 4ec1dd991405404725b5cc448295dc0be9cd17e5
2+
refs/heads/master: 2ac288383d22e8c4a18561293cfddd64a48e7b38
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/pipes.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,16 +1144,22 @@ proto! oneshot {
11441144
}
11451145
}
11461146

1147-
/// Receive a message from a oneshot pipe.
1147+
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
1148+
fn oneshot<T: send>() -> (oneshot::client::oneshot<T>,
1149+
oneshot::server::oneshot<T>) {
1150+
oneshot::init()
1151+
}
1152+
1153+
/**
1154+
* Receive a message from a oneshot pipe, failing if the connection was
1155+
* closed.
1156+
*/
11481157
fn recv_one<T: send>(+port: oneshot::server::oneshot<T>) -> T {
11491158
let oneshot::send(message) = recv(port);
11501159
message
11511160
}
11521161

1153-
/** Receive a message from a oneshot pipe, or fail if the connection
1154-
is closed.
1155-
1156-
*/
1162+
/// Receive a message from a oneshot pipe unless the connection was closed.
11571163
fn try_recv_one<T: send> (+port: oneshot::server::oneshot<T>) -> option<T> {
11581164
let message = try_recv(port);
11591165

@@ -1164,6 +1170,20 @@ fn try_recv_one<T: send> (+port: oneshot::server::oneshot<T>) -> option<T> {
11641170
}
11651171
}
11661172

1173+
/// Send a message on a oneshot pipe, failing if the connection was closed.
1174+
fn send_one<T: send>(+chan: oneshot::client::oneshot<T>, +data: T) {
1175+
oneshot::client::send(chan, data);
1176+
}
1177+
1178+
/**
1179+
* Send a message on a oneshot pipe, or return false if the connection was
1180+
* closed.
1181+
*/
1182+
fn try_send_one<T: send>(+chan: oneshot::client::oneshot<T>, +data: T)
1183+
-> bool {
1184+
oneshot::client::try_send(chan, data).is_some()
1185+
}
1186+
11671187
#[cfg(test)]
11681188
mod test {
11691189
#[test]

0 commit comments

Comments
 (0)