Skip to content

Commit badc580

Browse files
committed
Removing do keyword from libextra
1 parent d904179 commit badc580

File tree

8 files changed

+122
-123
lines changed

8 files changed

+122
-123
lines changed

src/libextra/arc.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
* let (port, chan) = Chan::new();
2929
* chan.send(shared_numbers.clone());
3030
*
31-
* do spawn {
31+
* spawn(proc() {
3232
* let shared_numbers = port.recv();
3333
* let local_numbers = shared_numbers.get();
3434
*
3535
* // Work with the local numbers
36-
* }
36+
* });
3737
* }
3838
* ```
3939
*/
@@ -567,12 +567,12 @@ mod tests {
567567

568568
let (p, c) = Chan::new();
569569

570-
do task::spawn {
570+
task::spawn(proc() {
571571
let arc_v: Arc<~[int]> = p.recv();
572572

573573
let v = arc_v.get().clone();
574574
assert_eq!(v[3], 4);
575-
};
575+
});
576576

577577
c.send(arc_v.clone());
578578

@@ -587,14 +587,14 @@ mod tests {
587587
let arc = ~MutexArc::new(false);
588588
let arc2 = ~arc.clone();
589589
let (p,c) = Chan::new();
590-
do task::spawn {
590+
task::spawn(proc() {
591591
// wait until parent gets in
592592
p.recv();
593593
arc2.access_cond(|state, cond| {
594594
*state = true;
595595
cond.signal();
596596
})
597-
}
597+
});
598598

599599
arc.access_cond(|state, cond| {
600600
c.send(());
@@ -611,14 +611,14 @@ mod tests {
611611
let arc2 = ~arc.clone();
612612
let (p, c) = Chan::new();
613613

614-
do spawn {
614+
spawn(proc() {
615615
let _ = p.recv();
616616
arc2.access_cond(|one, cond| {
617617
cond.signal();
618618
// Parent should fail when it wakes up.
619619
assert_eq!(*one, 0);
620620
})
621-
}
621+
});
622622

623623
arc.access_cond(|one, cond| {
624624
c.send(());
@@ -632,11 +632,11 @@ mod tests {
632632
fn test_mutex_arc_poison() {
633633
let arc = ~MutexArc::new(1);
634634
let arc2 = ~arc.clone();
635-
do task::try || {
635+
task::try(proc() {
636636
arc2.access(|one| {
637637
assert_eq!(*one, 2);
638638
})
639-
};
639+
});
640640
arc.access(|one| {
641641
assert_eq!(*one, 1);
642642
})
@@ -649,13 +649,13 @@ mod tests {
649649
// to underlaying data.
650650
let arc = ~MutexArc::new(1);
651651
let arc2 = ~MutexArc::new(*arc);
652-
do task::spawn || {
652+
task::spawn(proc() {
653653
(*arc2).unsafe_access(|mutex| {
654654
(*mutex).access(|one| {
655655
assert!(*one == 1);
656656
})
657657
})
658-
};
658+
});
659659
}
660660
}
661661

@@ -682,11 +682,11 @@ mod tests {
682682
fn test_rw_arc_poison_wr() {
683683
let arc = RWArc::new(1);
684684
let arc2 = arc.clone();
685-
do task::try {
685+
task::try(proc() {
686686
arc2.write(|one| {
687687
assert_eq!(*one, 2);
688688
})
689-
};
689+
});
690690
arc.read(|one| {
691691
assert_eq!(*one, 1);
692692
})
@@ -696,11 +696,11 @@ mod tests {
696696
fn test_rw_arc_poison_ww() {
697697
let arc = RWArc::new(1);
698698
let arc2 = arc.clone();
699-
do task::try {
699+
task::try(proc() {
700700
arc2.write(|one| {
701701
assert_eq!(*one, 2);
702702
})
703-
};
703+
});
704704
arc.write(|one| {
705705
assert_eq!(*one, 1);
706706
})
@@ -709,13 +709,13 @@ mod tests {
709709
fn test_rw_arc_poison_dw() {
710710
let arc = RWArc::new(1);
711711
let arc2 = arc.clone();
712-
do task::try {
712+
task::try(proc() {
713713
arc2.write_downgrade(|mut write_mode| {
714714
write_mode.write(|one| {
715715
assert_eq!(*one, 2);
716716
})
717717
})
718-
};
718+
});
719719
arc.write(|one| {
720720
assert_eq!(*one, 1);
721721
})
@@ -724,11 +724,11 @@ mod tests {
724724
fn test_rw_arc_no_poison_rr() {
725725
let arc = RWArc::new(1);
726726
let arc2 = arc.clone();
727-
do task::try {
727+
task::try(proc() {
728728
arc2.read(|one| {
729729
assert_eq!(*one, 2);
730730
})
731-
};
731+
});
732732
arc.read(|one| {
733733
assert_eq!(*one, 1);
734734
})
@@ -737,11 +737,11 @@ mod tests {
737737
fn test_rw_arc_no_poison_rw() {
738738
let arc = RWArc::new(1);
739739
let arc2 = arc.clone();
740-
do task::try {
740+
task::try(proc() {
741741
arc2.read(|one| {
742742
assert_eq!(*one, 2);
743743
})
744-
};
744+
});
745745
arc.write(|one| {
746746
assert_eq!(*one, 1);
747747
})
@@ -750,14 +750,14 @@ mod tests {
750750
fn test_rw_arc_no_poison_dr() {
751751
let arc = RWArc::new(1);
752752
let arc2 = arc.clone();
753-
do task::try {
753+
task::try(proc() {
754754
arc2.write_downgrade(|write_mode| {
755755
let read_mode = arc2.downgrade(write_mode);
756756
read_mode.read(|one| {
757757
assert_eq!(*one, 2);
758758
})
759759
})
760-
};
760+
});
761761
arc.write(|one| {
762762
assert_eq!(*one, 1);
763763
})
@@ -768,7 +768,7 @@ mod tests {
768768
let arc2 = arc.clone();
769769
let (p, c) = Chan::new();
770770

771-
do task::spawn {
771+
task::spawn(proc() {
772772
arc2.write(|num| {
773773
10.times(|| {
774774
let tmp = *num;
@@ -778,19 +778,19 @@ mod tests {
778778
});
779779
c.send(());
780780
})
781-
}
781+
});
782782

783783
// Readers try to catch the writer in the act
784784
let mut children = ~[];
785785
5.times(|| {
786786
let arc3 = arc.clone();
787787
let mut builder = task::task();
788788
children.push(builder.future_result());
789-
do builder.spawn {
789+
builder.spawn(proc() {
790790
arc3.read(|num| {
791791
assert!(*num >= 0);
792792
})
793-
}
793+
});
794794
});
795795

796796
// Wait for children to pass their asserts
@@ -840,19 +840,19 @@ mod tests {
840840
let ((rp1, rc1), (rp2, rc2)) = (Chan::new(), Chan::new());
841841
reader_convos.push((rc1, rp2));
842842
let arcn = arc.clone();
843-
do task::spawn {
843+
task::spawn(proc() {
844844
rp1.recv(); // wait for downgrader to give go-ahead
845845
arcn.read(|state| {
846846
assert_eq!(*state, 31337);
847847
rc2.send(());
848848
})
849-
}
849+
});
850850
});
851851

852852
// Writer task
853853
let arc2 = arc.clone();
854854
let ((wp1, wc1), (wp2, wc2)) = (Chan::new(), Chan::new());
855-
do task::spawn || {
855+
task::spawn(proc() {
856856
wp1.recv();
857857
arc2.write_cond(|state, cond| {
858858
assert_eq!(*state, 0);
@@ -867,7 +867,7 @@ mod tests {
867867
*state = 42;
868868
});
869869
wc2.send(());
870-
}
870+
});
871871

872872
// Downgrader (us)
873873
arc.write_downgrade(|mut write_mode| {
@@ -912,7 +912,7 @@ mod tests {
912912

913913
// writer task
914914
let xw = x.clone();
915-
do task::spawn {
915+
task::spawn(proc() {
916916
xw.write_cond(|state, c| {
917917
wc.send(()); // tell downgrader it's ok to go
918918
c.wait();
@@ -921,7 +921,7 @@ mod tests {
921921
// trying to receive the "reader cloud lock hand-off".
922922
*state = false;
923923
})
924-
}
924+
});
925925

926926
wp.recv(); // wait for writer to get in
927927

@@ -934,10 +934,10 @@ mod tests {
934934
// make a reader task to trigger the "reader cloud lock" handoff
935935
let xr = x.clone();
936936
let (rp, rc) = Chan::new();
937-
do task::spawn {
937+
task::spawn(proc() {
938938
rc.send(());
939939
xr.read(|_state| { })
940-
}
940+
});
941941
rp.recv(); // wait for reader task to exist
942942

943943
let read_mode = x.downgrade(write_mode);

src/libextra/comm.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ mod test {
115115
pub fn basic_rendezvous_test() {
116116
let (port, chan) = rendezvous();
117117
118-
do spawn {
118+
spawn(proc() {
119119
chan.send("abc");
120-
}
120+
});
121121
122122
assert!(port.recv() == "abc");
123123
}
@@ -126,40 +126,40 @@ mod test {
126126
fn recv_a_lot() {
127127
// Rendezvous streams should be able to handle any number of messages being sent
128128
let (port, chan) = rendezvous();
129-
do spawn {
129+
spawn(proc() {
130130
10000.times(|| { chan.send(()) })
131-
}
131+
});
132132
10000.times(|| { port.recv() })
133133
}
134134

135135
#[test]
136136
fn send_and_fail_and_try_recv() {
137137
let (port, chan) = rendezvous();
138-
do spawn {
138+
spawn(proc() {
139139
chan.duplex_stream.send(()); // Can't access this field outside this module
140140
fail!()
141-
}
141+
});
142142
port.recv()
143143
}
144144

145145
#[test]
146146
fn try_send_and_recv_then_fail_before_ack() {
147147
let (port, chan) = rendezvous();
148-
do spawn {
148+
spawn(proc() {
149149
port.duplex_stream.recv();
150150
fail!()
151-
}
151+
});
152152
chan.try_send(());
153153
}
154154

155155
#[test]
156156
#[should_fail]
157157
fn send_and_recv_then_fail_before_ack() {
158158
let (port, chan) = rendezvous();
159-
do spawn {
159+
spawn(proc() {
160160
port.duplex_stream.recv();
161161
fail!()
162-
}
162+
});
163163
chan.send(());
164164
}
165165
}

src/libextra/dlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,10 @@ mod tests {
971971
#[test]
972972
fn test_send() {
973973
let n = list_from([1,2,3]);
974-
do spawn {
974+
spawn(proc() {
975975
check_links(&n);
976976
assert_eq!(~[&1,&2,&3], n.iter().collect::<~[&int]>());
977-
}
977+
});
978978
}
979979

980980
#[test]

src/libextra/future.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* use extra::future::Future;
1919
* # fn fib(n: uint) -> uint {42};
2020
* # fn make_a_sandwich() {};
21-
* let mut delayed_fib = do Future::spawn { fib(5000) };
21+
* let mut delayed_fib = Future::spawn(proc() { fib(5000) });
2222
* make_a_sandwich();
2323
* println!("fib(5000) = {}", delayed_fib.get())
2424
* ```
@@ -112,9 +112,9 @@ impl<A:Send> Future<A> {
112112
* waiting for the result to be received on the port.
113113
*/
114114

115-
do Future::from_fn {
115+
Future::from_fn(proc() {
116116
port.recv()
117-
}
117+
})
118118
}
119119

120120
pub fn spawn(blk: proc() -> A) -> Future<A> {
@@ -127,9 +127,9 @@ impl<A:Send> Future<A> {
127127

128128
let (port, chan) = Chan::new();
129129

130-
do spawn {
130+
spawn(proc() {
131131
chan.send(blk());
132-
}
132+
});
133133

134134
Future::from_port(port)
135135
}
@@ -195,11 +195,11 @@ mod test {
195195
#[test]
196196
fn test_sendable_future() {
197197
let expected = "schlorf";
198-
let f = do Future::spawn { expected };
199-
do task::spawn {
198+
let f = Future::spawn(proc() { expected });
199+
task::spawn(proc() {
200200
let mut f = f;
201201
let actual = f.get();
202202
assert_eq!(actual, expected);
203-
}
203+
});
204204
}
205205
}

0 commit comments

Comments
 (0)