Skip to content

Commit 5349e2f

Browse files
committed
---
yaml --- r: 29840 b: refs/heads/incoming c: fa8fc4b h: refs/heads/master v: v3
1 parent 207d73b commit 5349e2f

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: a63f85ce8c48a819c341f247ef451eb2160b30b1
9+
refs/heads/incoming: fa8fc4b2b5bc66aa7b10a04a895c33de0d5e8185
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/pipes.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export send_packet, recv_packet, send, recv, try_recv, peek;
9090
export select, select2, selecti, select2i, selectable;
9191
export spawn_service, spawn_service_recv;
9292
export stream, port, chan, shared_chan, port_set, channel;
93-
export oneshot, recv_one, try_recv_one, send_one, try_send_one;
93+
export oneshot, chan_one, port_one;
94+
export recv_one, try_recv_one, send_one, try_send_one;
9495

9596
#[doc(hidden)]
9697
const SPIN_COUNT: uint = 0;
@@ -1144,23 +1145,27 @@ proto! oneshot {
11441145
}
11451146
}
11461147

1148+
/// The send end of a oneshot pipe.
1149+
type chan_one<T: send> = oneshot::client::oneshot<T>;
1150+
/// The receive end of a oneshot pipe.
1151+
type port_one<T: send> = oneshot::server::oneshot<T>;
1152+
11471153
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
1148-
fn oneshot<T: send>() -> (oneshot::client::oneshot<T>,
1149-
oneshot::server::oneshot<T>) {
1154+
fn oneshot<T: send>() -> (chan_one<T>, port_one<T>) {
11501155
oneshot::init()
11511156
}
11521157

11531158
/**
11541159
* Receive a message from a oneshot pipe, failing if the connection was
11551160
* closed.
11561161
*/
1157-
fn recv_one<T: send>(+port: oneshot::server::oneshot<T>) -> T {
1162+
fn recv_one<T: send>(+port: port_one<T>) -> T {
11581163
let oneshot::send(message) = recv(port);
11591164
message
11601165
}
11611166

11621167
/// Receive a message from a oneshot pipe unless the connection was closed.
1163-
fn try_recv_one<T: send> (+port: oneshot::server::oneshot<T>) -> option<T> {
1168+
fn try_recv_one<T: send> (+port: port_one<T>) -> option<T> {
11641169
let message = try_recv(port);
11651170

11661171
if message == none { none }
@@ -1171,15 +1176,15 @@ fn try_recv_one<T: send> (+port: oneshot::server::oneshot<T>) -> option<T> {
11711176
}
11721177

11731178
/// 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) {
1179+
fn send_one<T: send>(+chan: chan_one<T>, +data: T) {
11751180
oneshot::client::send(chan, data);
11761181
}
11771182

11781183
/**
11791184
* Send a message on a oneshot pipe, or return false if the connection was
11801185
* closed.
11811186
*/
1182-
fn try_send_one<T: send>(+chan: oneshot::client::oneshot<T>, +data: T)
1187+
fn try_send_one<T: send>(+chan: chan_one<T>, +data: T)
11831188
-> bool {
11841189
oneshot::client::try_send(chan, data).is_some()
11851190
}

branches/incoming/src/libstd/sync.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import unsafe::{Exclusive, exclusive};
1818
****************************************************************************/
1919

2020
// Each waiting task receives on one of these. FIXME #3125 make these oneshot.
21-
type wait_end = pipes::port<()>;
22-
type signal_end = pipes::chan<()>;
21+
type wait_end = pipes::port_one<()>;
22+
type signal_end = pipes::chan_one<()>;
2323
// A doubly-ended queue of waiting tasks.
2424
struct waitqueue { head: pipes::port<signal_end>;
2525
tail: pipes::chan<signal_end>; }
@@ -30,7 +30,7 @@ fn signal_waitqueue(q: &waitqueue) -> bool {
3030
if q.head.peek() {
3131
// Pop and send a wakeup signal. If the waiter was killed, its port
3232
// will have closed. Keep trying until we get a live task.
33-
if q.head.recv().try_send(()) {
33+
if pipes::try_send_one(q.head.recv(), ()) {
3434
true
3535
} else {
3636
signal_waitqueue(q)
@@ -43,7 +43,7 @@ fn signal_waitqueue(q: &waitqueue) -> bool {
4343
fn broadcast_waitqueue(q: &waitqueue) -> uint {
4444
let mut count = 0;
4545
while q.head.peek() {
46-
if q.head.recv().try_send(()) {
46+
if pipes::try_send_one(q.head.recv(), ()) {
4747
count += 1;
4848
}
4949
}
@@ -80,7 +80,7 @@ impl<Q: send> &sem<Q> {
8080
state.count -= 1;
8181
if state.count < 0 {
8282
// Create waiter nobe.
83-
let (signal_end, wait_end) = pipes::stream();
83+
let (signal_end, wait_end) = pipes::oneshot();
8484
// Tell outer scope we need to block.
8585
waiter_nobe = some(wait_end);
8686
// Enqueue ourself.
@@ -92,7 +92,7 @@ impl<Q: send> &sem<Q> {
9292
/* for 1000.times { task::yield(); } */
9393
// Need to wait outside the exclusive.
9494
if waiter_nobe.is_some() {
95-
let _ = option::unwrap(waiter_nobe).recv();
95+
let _ = pipes::recv_one(option::unwrap(waiter_nobe));
9696
}
9797
}
9898
fn release() {
@@ -151,7 +151,7 @@ impl &condvar {
151151
/// Atomically drop the associated lock, and block until a signal is sent.
152152
fn wait() {
153153
// Create waiter nobe.
154-
let (signal_end, wait_end) = pipes::stream();
154+
let (signal_end, wait_end) = pipes::oneshot();
155155
let mut signal_end = some(signal_end);
156156
let mut reacquire = none;
157157
unsafe {
@@ -177,7 +177,7 @@ impl &condvar {
177177
}
178178
// Unconditionally "block". (Might not actually block if a signaller
179179
// did send -- I mean 'unconditionally' in contrast with acquire().)
180-
let _ = wait_end.recv();
180+
let _ = pipes::recv_one(wait_end);
181181

182182
// This is needed for a failing condition variable to reacquire the
183183
// mutex during unwinding. As long as the wrapper (mutex, etc) is

0 commit comments

Comments
 (0)