Skip to content

Commit 38bd694

Browse files
committed
Reverse the order of the results of pipes::stream
As per #3637.
1 parent b0a01f2 commit 38bd694

27 files changed

+81
-81
lines changed

src/libcore/pipes.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,10 @@ pub enum Port<T:Send> {
978978
These allow sending or receiving an unlimited number of messages.
979979
980980
*/
981-
pub fn stream<T:Send>() -> (Chan<T>, Port<T>) {
981+
pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
982982
let (c, s) = streamp::init();
983983

984-
(Chan_({ mut endp: Some(move c) }), Port_({ mut endp: Some(move s) }))
984+
(Port_({ mut endp: Some(move s) }), Chan_({ mut endp: Some(move c) }))
985985
}
986986

987987
impl<T: Send> Chan<T>: GenericChan<T> {
@@ -1070,7 +1070,7 @@ impl<T: Send> PortSet<T> {
10701070
}
10711071

10721072
fn chan() -> Chan<T> {
1073-
let (ch, po) = stream();
1073+
let (po, ch) = stream();
10741074
self.add(move po);
10751075
move ch
10761076
}
@@ -1240,8 +1240,8 @@ pub mod rt {
12401240
pub mod test {
12411241
#[test]
12421242
pub fn test_select2() {
1243-
let (c1, p1) = pipes::stream();
1244-
let (c2, p2) = pipes::stream();
1243+
let (p1, c1) = pipes::stream();
1244+
let (p2, c2) = pipes::stream();
12451245

12461246
c1.send(~"abc");
12471247

@@ -1264,7 +1264,7 @@ pub mod test {
12641264

12651265
#[test]
12661266
fn test_peek_terminated() {
1267-
let (chan, port): (Chan<int>, Port<int>) = stream();
1267+
let (port, chan): (Port<int>, Chan<int>) = stream();
12681268

12691269
{
12701270
// Destroy the channel

src/libcore/private.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ pub mod tests {
576576

577577
for uint::range(0, num_tasks) |_i| {
578578
let total = total.clone();
579-
let (chan, port) = pipes::stream();
579+
let (port, chan) = pipes::stream();
580580
futures.push(move port);
581581

582582
do task::spawn |move total, move chan| {

src/libcore/task/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl TaskBuilder {
340340
}
341341
342342
// Construct the future and give it to the caller.
343-
let (notify_pipe_ch, notify_pipe_po) = stream::<TaskResult>();
343+
let (notify_pipe_po, notify_pipe_ch) = stream::<TaskResult>();
344344
345345
blk(move notify_pipe_po);
346346
@@ -1211,7 +1211,7 @@ fn test_unkillable() {
12111211
#[ignore(cfg(windows))]
12121212
#[should_fail]
12131213
fn test_unkillable_nested() {
1214-
let (ch, po) = pipes::stream();
1214+
let (po, ch) = pipes::stream();
12151215

12161216
// We want to do this after failing
12171217
do spawn_unlinked |move ch| {
@@ -1277,7 +1277,7 @@ fn test_child_doesnt_ref_parent() {
12771277

12781278
#[test]
12791279
fn test_sched_thread_per_core() {
1280-
let (chan, port) = pipes::stream();
1280+
let (port, chan) = pipes::stream();
12811281

12821282
do spawn_sched(ThreadPerCore) |move chan| {
12831283
let cores = rt::rust_num_threads();
@@ -1291,15 +1291,15 @@ fn test_sched_thread_per_core() {
12911291

12921292
#[test]
12931293
fn test_spawn_thread_on_demand() {
1294-
let (chan, port) = pipes::stream();
1294+
let (port, chan) = pipes::stream();
12951295

12961296
do spawn_sched(ManualThreads(2)) |move chan| {
12971297
let max_threads = rt::rust_sched_threads();
12981298
assert(max_threads as int == 2);
12991299
let running_threads = rt::rust_sched_current_nonlazy_threads();
13001300
assert(running_threads as int == 1);
13011301

1302-
let (chan2, port2) = pipes::stream();
1302+
let (port2, chan2) = pipes::stream();
13031303

13041304
do spawn() |move chan2| {
13051305
chan2.send(());

src/libcore/task/spawn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ fn test_spawn_raw_unsupervise() {
670670
#[test]
671671
#[ignore(cfg(windows))]
672672
fn test_spawn_raw_notify_success() {
673-
let (notify_ch, notify_po) = pipes::stream();
673+
let (notify_po, notify_ch) = pipes::stream();
674674

675675
let opts = {
676676
notify_chan: Some(move notify_ch),
@@ -685,7 +685,7 @@ fn test_spawn_raw_notify_success() {
685685
#[ignore(cfg(windows))]
686686
fn test_spawn_raw_notify_failure() {
687687
// New bindings for these
688-
let (notify_ch, notify_po) = pipes::stream();
688+
let (notify_po, notify_ch) = pipes::stream();
689689

690690
let opts = {
691691
linked: false,

src/librustdoc/markdown_writer.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ fn pandoc_writer(
111111
os::close(pipe_err.out);
112112
os::close(pipe_in.out);
113113
114-
let (stdout_ch, stdout_po) = pipes::stream();
114+
let (stdout_po, stdout_ch) = pipes::stream();
115115
do task::spawn_sched(task::SingleThreaded) |move stdout_ch| {
116116
stdout_ch.send(readclose(pipe_out.in));
117117
}
118118
119-
let (stderr_ch, stderr_po) = pipes::stream();
119+
let (stderr_po, stderr_ch) = pipes::stream();
120120
do task::spawn_sched(task::SingleThreaded) |move stderr_ch| {
121121
stderr_ch.send(readclose(pipe_err.in));
122122
}
@@ -149,7 +149,7 @@ fn readclose(fd: libc::c_int) -> ~str {
149149
}
150150
151151
fn generic_writer(+process: fn~(+markdown: ~str)) -> Writer {
152-
let (setup_ch, setup_po) = pipes::stream();
152+
let (setup_po, setup_ch) = pipes::stream();
153153
do task::spawn |move process, move setup_ch| {
154154
let po: comm::Port<WriteInstr> = comm::Port();
155155
let ch = comm::Chan(&po);
@@ -279,7 +279,7 @@ pub fn future_writer_factory(
279279
let markdown_po = comm::Port();
280280
let markdown_ch = comm::Chan(&markdown_po);
281281
let writer_factory = fn~(+page: doc::Page) -> Writer {
282-
let (writer_ch, writer_po) = pipes::stream();
282+
let (writer_po, writer_ch) = pipes::stream();
283283
do task::spawn |move writer_ch| {
284284
let (writer, future) = future_writer();
285285
writer_ch.send(move writer);
@@ -293,7 +293,7 @@ pub fn future_writer_factory(
293293
}
294294
295295
fn future_writer() -> (Writer, future::Future<~str>) {
296-
let (chan, port) = pipes::stream();
296+
let (port, chan) = pipes::stream();
297297
let writer = fn~(move chan, +instr: WriteInstr) {
298298
chan.send(copy instr);
299299
};

src/libstd/arc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ mod tests {
471471
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
472472
let arc_v = arc::ARC(v);
473473

474-
let (c, p) = pipes::stream();
474+
let (p, c) = pipes::stream();
475475

476476
do task::spawn() |move c| {
477477
let p = pipes::PortSet();
@@ -517,7 +517,7 @@ mod tests {
517517
fn test_arc_condvar_poison() {
518518
let arc = ~MutexARC(1);
519519
let arc2 = ~arc.clone();
520-
let (c,p) = pipes::stream();
520+
let (p, c) = pipes::stream();
521521

522522
do task::spawn_unlinked |move arc2, move p| {
523523
let _ = p.recv();
@@ -551,7 +551,7 @@ mod tests {
551551
fn test_mutex_arc_unwrap_poison() {
552552
let arc = MutexARC(1);
553553
let arc2 = ~(&arc).clone();
554-
let (c,p) = pipes::stream();
554+
let (p, c) = pipes::stream();
555555
do task::spawn |move c, move arc2| {
556556
do arc2.access |one| {
557557
c.send(());
@@ -649,7 +649,7 @@ mod tests {
649649
fn test_rw_arc() {
650650
let arc = ~RWARC(0);
651651
let arc2 = ~arc.clone();
652-
let (c,p) = pipes::stream();
652+
let (p,c) = pipes::stream();
653653

654654
do task::spawn |move arc2, move c| {
655655
do arc2.write |num| {
@@ -695,7 +695,7 @@ mod tests {
695695
// Reader tasks
696696
let mut reader_convos = ~[];
697697
for 10.times {
698-
let ((rc1,rp1),(rc2,rp2)) = (pipes::stream(),pipes::stream());
698+
let ((rp1,rc1),(rp2,rc2)) = (pipes::stream(),pipes::stream());
699699
reader_convos.push((move rc1, move rp2));
700700
let arcn = ~arc.clone();
701701
do task::spawn |move rp1, move rc2, move arcn| {
@@ -709,7 +709,7 @@ mod tests {
709709

710710
// Writer task
711711
let arc2 = ~arc.clone();
712-
let ((wc1,wp1),(wc2,wp2)) = (pipes::stream(),pipes::stream());
712+
let ((wp1,wc1),(wp2,wc2)) = (pipes::stream(),pipes::stream());
713713
do task::spawn |move arc2, move wc2, move wp1| {
714714
wp1.recv();
715715
do arc2.write_cond |state, cond| {

src/libstd/comm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ impl<T: Send, U: Send> DuplexStream<T, U> : Selectable {
6464
pub fn DuplexStream<T: Send, U: Send>()
6565
-> (DuplexStream<T, U>, DuplexStream<U, T>)
6666
{
67-
let (c2, p1) = pipes::stream();
68-
let (c1, p2) = pipes::stream();
67+
let (p1, c2) = pipes::stream();
68+
let (p2, c1) = pipes::stream();
6969
(DuplexStream {
7070
chan: move c1,
7171
port: move p1

src/libstd/sync.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Waitqueue { head: pipes::Port<SignalEnd>,
3434
tail: pipes::Chan<SignalEnd> }
3535

3636
fn new_waitqueue() -> Waitqueue {
37-
let (block_tail, block_head) = pipes::stream();
37+
let (block_head, block_tail) = pipes::stream();
3838
Waitqueue { head: move block_head, tail: move block_tail }
3939
}
4040

@@ -733,7 +733,7 @@ mod tests {
733733
#[test]
734734
fn test_sem_as_cvar() {
735735
/* Child waits and parent signals */
736-
let (c,p) = pipes::stream();
736+
let (p,c) = pipes::stream();
737737
let s = ~semaphore(0);
738738
let s2 = ~s.clone();
739739
do task::spawn |move s2, move c| {
@@ -745,7 +745,7 @@ mod tests {
745745
let _ = p.recv();
746746

747747
/* Parent waits and child signals */
748-
let (c,p) = pipes::stream();
748+
let (p,c) = pipes::stream();
749749
let s = ~semaphore(0);
750750
let s2 = ~s.clone();
751751
do task::spawn |move s2, move p| {
@@ -762,8 +762,8 @@ mod tests {
762762
// time, and shake hands.
763763
let s = ~semaphore(2);
764764
let s2 = ~s.clone();
765-
let (c1,p1) = pipes::stream();
766-
let (c2,p2) = pipes::stream();
765+
let (p1,c1) = pipes::stream();
766+
let (p2,c2) = pipes::stream();
767767
do task::spawn |move s2, move c1, move p2| {
768768
do s2.access {
769769
let _ = p2.recv();
@@ -782,7 +782,7 @@ mod tests {
782782
do task::spawn_sched(task::ManualThreads(1)) {
783783
let s = ~semaphore(1);
784784
let s2 = ~s.clone();
785-
let (c,p) = pipes::stream();
785+
let (p,c) = pipes::stream();
786786
let child_data = ~mut Some((move s2, move c));
787787
do s.access {
788788
let (s2,c) = option::swap_unwrap(child_data);
@@ -804,7 +804,7 @@ mod tests {
804804
fn test_mutex_lock() {
805805
// Unsafely achieve shared state, and do the textbook
806806
// "load tmp = move ptr; inc tmp; store ptr <- tmp" dance.
807-
let (c,p) = pipes::stream();
807+
let (p,c) = pipes::stream();
808808
let m = ~Mutex();
809809
let m2 = ~m.clone();
810810
let mut sharedstate = ~0;
@@ -847,7 +847,7 @@ mod tests {
847847
cond.wait();
848848
}
849849
// Parent wakes up child
850-
let (chan,port) = pipes::stream();
850+
let (port,chan) = pipes::stream();
851851
let m3 = ~m.clone();
852852
do task::spawn |move chan, move m3| {
853853
do m3.lock_cond |cond| {
@@ -870,7 +870,7 @@ mod tests {
870870

871871
for num_waiters.times {
872872
let mi = ~m.clone();
873-
let (chan, port) = pipes::stream();
873+
let (port, chan) = pipes::stream();
874874
ports.push(move port);
875875
do task::spawn |move chan, move mi| {
876876
do mi.lock_cond |cond| {
@@ -932,7 +932,7 @@ mod tests {
932932
let m2 = ~m.clone();
933933

934934
let result: result::Result<(),()> = do task::try |move m2| {
935-
let (c,p) = pipes::stream();
935+
let (p,c) = pipes::stream();
936936
do task::spawn |move p| { // linked
937937
let _ = p.recv(); // wait for sibling to get in the mutex
938938
task::yield();
@@ -954,12 +954,12 @@ mod tests {
954954
fn test_mutex_killed_broadcast() {
955955
let m = ~Mutex();
956956
let m2 = ~m.clone();
957-
let (c,p) = pipes::stream();
957+
let (p,c) = pipes::stream();
958958

959959
let result: result::Result<(),()> = do task::try |move c, move m2| {
960960
let mut sibling_convos = ~[];
961961
for 2.times {
962-
let (c,p) = pipes::stream();
962+
let (p,c) = pipes::stream();
963963
let c = ~mut Some(move c);
964964
sibling_convos.push(move p);
965965
let mi = ~m2.clone();
@@ -1022,7 +1022,7 @@ mod tests {
10221022
let result = do task::try {
10231023
let m = ~mutex_with_condvars(2);
10241024
let m2 = ~m.clone();
1025-
let (c,p) = pipes::stream();
1025+
let (p,c) = pipes::stream();
10261026
do task::spawn |move m2, move c| {
10271027
do m2.lock_cond |cond| {
10281028
c.send(());
@@ -1082,7 +1082,7 @@ mod tests {
10821082
mode2: RWlockMode) {
10831083
// Test mutual exclusion between readers and writers. Just like the
10841084
// mutex mutual exclusion test, a ways above.
1085-
let (c,p) = pipes::stream();
1085+
let (p,c) = pipes::stream();
10861086
let x2 = ~x.clone();
10871087
let mut sharedstate = ~0;
10881088
let ptr = ptr::addr_of(&(*sharedstate));
@@ -1127,8 +1127,8 @@ mod tests {
11271127
mode2: RWlockMode, make_mode2_go_first: bool) {
11281128
// Much like sem_multi_resource.
11291129
let x2 = ~x.clone();
1130-
let (c1,p1) = pipes::stream();
1131-
let (c2,p2) = pipes::stream();
1130+
let (p1,c1) = pipes::stream();
1131+
let (p2,c2) = pipes::stream();
11321132
do task::spawn |move c1, move x2, move p2| {
11331133
if !make_mode2_go_first {
11341134
let _ = p2.recv(); // parent sends to us once it locks, or ...
@@ -1193,7 +1193,7 @@ mod tests {
11931193
cond.wait();
11941194
}
11951195
// Parent wakes up child
1196-
let (chan,port) = pipes::stream();
1196+
let (port,chan) = pipes::stream();
11971197
let x3 = ~x.clone();
11981198
do task::spawn |move x3, move chan| {
11991199
do x3.write_cond |cond| {
@@ -1229,7 +1229,7 @@ mod tests {
12291229

12301230
for num_waiters.times {
12311231
let xi = ~x.clone();
1232-
let (chan, port) = pipes::stream();
1232+
let (port, chan) = pipes::stream();
12331233
ports.push(move port);
12341234
do task::spawn |move chan, move xi| {
12351235
do lock_cond(xi, dg1) |cond| {

src/libstd/task_pool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub impl<T> TaskPool<T> {
4242
assert n_tasks >= 1;
4343

4444
let channels = do vec::from_fn(n_tasks) |i| {
45-
let (chan, port) = pipes::stream::<Msg<T>>();
45+
let (port, chan) = pipes::stream::<Msg<T>>();
4646
let init_fn = init_fn_factory();
4747

4848
let task_body: ~fn() = |move port, move init_fn| {

src/test/bench/msgsend-pipes-shared.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ fn server(requests: Port<request>, responses: pipes::Chan<uint>) {
5555
}
5656

5757
fn run(args: &[~str]) {
58-
let (to_parent, from_child) = pipes::stream();
59-
let (to_child, from_parent) = pipes::stream();
58+
let (from_child, to_parent) = pipes::stream();
59+
let (from_parent, to_child) = pipes::stream();
6060

6161
let to_child = SharedChan(move to_child);
6262

0 commit comments

Comments
 (0)