@@ -572,10 +572,10 @@ mod tests {
572
572
573
573
let (p, c) = comm::stream();
574
574
575
- do task::spawn() || {
576
- let arc_v : Arc<~[int]> = p.recv();
575
+ do task::spawn {
576
+ let arc_v: Arc<~[int]> = p.recv();
577
577
578
- let v = (* arc_v.get() ).clone();
578
+ let v = arc_v.get().clone();
579
579
assert_eq!(v[3], 4);
580
580
};
581
581
@@ -590,11 +590,11 @@ mod tests {
590
590
#[test]
591
591
fn test_mutex_arc_condvar() {
592
592
unsafe {
593
- let arc = ~ MutexArc::new(false);
594
- let arc2 = ~ arc.clone();
595
- let (p,c) = comm::oneshot();
596
- let (c,p) = (Cell::new(c), Cell::new(p));
597
- do task::spawn || {
593
+ let arc = MutexArc::new(false);
594
+ let arc2 = arc.clone();
595
+ let (p, c) = comm::oneshot();
596
+ let (c, p) = (Cell::new(c), Cell::new(p));
597
+ do task::spawn {
598
598
// wait until parent gets in
599
599
p.take().recv();
600
600
do arc2.access_cond |state, cond| {
@@ -615,11 +615,11 @@ mod tests {
615
615
#[test] #[should_fail]
616
616
fn test_arc_condvar_poison() {
617
617
unsafe {
618
- let arc = ~ MutexArc::new(1);
619
- let arc2 = ~ arc.clone();
618
+ let arc = MutexArc::new(1);
619
+ let arc2 = arc.clone();
620
620
let (p, c) = comm::stream();
621
621
622
- do task::spawn_unlinked || {
622
+ do task::spawn_unlinked {
623
623
let _ = p.recv();
624
624
do arc2.access_cond |one, cond| {
625
625
cond.signal();
@@ -639,9 +639,9 @@ mod tests {
639
639
#[test] #[should_fail]
640
640
fn test_mutex_arc_poison() {
641
641
unsafe {
642
- let arc = ~ MutexArc::new(1);
643
- let arc2 = ~ arc.clone();
644
- do task::try || {
642
+ let arc = MutexArc::new(1);
643
+ let arc2 = arc.clone();
644
+ do task::try {
645
645
do arc2.access |one| {
646
646
assert_eq!(*one, 2);
647
647
}
@@ -654,7 +654,7 @@ mod tests {
654
654
#[test] #[should_fail]
655
655
pub fn test_mutex_arc_unwrap_poison() {
656
656
let arc = MutexArc::new(1);
657
- let arc2 = ~(& arc) .clone();
657
+ let arc2 = arc.clone();
658
658
let (p, c) = comm::stream();
659
659
do task::spawn {
660
660
unsafe {
@@ -670,9 +670,9 @@ mod tests {
670
670
}
671
671
#[test] #[should_fail]
672
672
fn test_rw_arc_poison_wr() {
673
- let arc = ~ RWArc::new(1);
674
- let arc2 = (* arc) .clone();
675
- do task::try || {
673
+ let arc = RWArc::new(1);
674
+ let arc2 = arc.clone();
675
+ do task::try {
676
676
do arc2.write |one| {
677
677
assert_eq!(*one, 2);
678
678
}
@@ -683,9 +683,9 @@ mod tests {
683
683
}
684
684
#[test] #[should_fail]
685
685
fn test_rw_arc_poison_ww() {
686
- let arc = ~ RWArc::new(1);
687
- let arc2 = (* arc) .clone();
688
- do task::try || {
686
+ let arc = RWArc::new(1);
687
+ let arc2 = arc.clone();
688
+ do task::try {
689
689
do arc2.write |one| {
690
690
assert_eq!(*one, 2);
691
691
}
@@ -696,9 +696,9 @@ mod tests {
696
696
}
697
697
#[test] #[should_fail]
698
698
fn test_rw_arc_poison_dw() {
699
- let arc = ~ RWArc::new(1);
700
- let arc2 = (* arc) .clone();
701
- do task::try || {
699
+ let arc = RWArc::new(1);
700
+ let arc2 = arc.clone();
701
+ do task::try {
702
702
do arc2.write_downgrade |mut write_mode| {
703
703
do write_mode.write |one| {
704
704
assert_eq!(*one, 2);
@@ -711,9 +711,9 @@ mod tests {
711
711
}
712
712
#[test]
713
713
fn test_rw_arc_no_poison_rr() {
714
- let arc = ~ RWArc::new(1);
715
- let arc2 = (* arc) .clone();
716
- do task::try || {
714
+ let arc = RWArc::new(1);
715
+ let arc2 = arc.clone();
716
+ do task::try {
717
717
do arc2.read |one| {
718
718
assert_eq!(*one, 2);
719
719
}
@@ -724,9 +724,9 @@ mod tests {
724
724
}
725
725
#[test]
726
726
fn test_rw_arc_no_poison_rw() {
727
- let arc = ~ RWArc::new(1);
728
- let arc2 = (* arc) .clone();
729
- do task::try || {
727
+ let arc = RWArc::new(1);
728
+ let arc2 = arc.clone();
729
+ do task::try {
730
730
do arc2.read |one| {
731
731
assert_eq!(*one, 2);
732
732
}
@@ -737,12 +737,12 @@ mod tests {
737
737
}
738
738
#[test]
739
739
fn test_rw_arc_no_poison_dr() {
740
- let arc = ~ RWArc::new(1);
741
- let arc2 = (* arc) .clone();
742
- do task::try || {
740
+ let arc = RWArc::new(1);
741
+ let arc2 = arc.clone();
742
+ do task::try {
743
743
do arc2.write_downgrade |write_mode| {
744
744
let read_mode = arc2.downgrade(write_mode);
745
- do (& read_mode) .read |one| {
745
+ do read_mode.read |one| {
746
746
assert_eq!(*one, 2);
747
747
}
748
748
}
@@ -753,11 +753,11 @@ mod tests {
753
753
}
754
754
#[test]
755
755
fn test_rw_arc() {
756
- let arc = ~ RWArc::new(0);
757
- let arc2 = (* arc) .clone();
758
- let (p,c) = comm::stream();
756
+ let arc = RWArc::new(0);
757
+ let arc2 = arc.clone();
758
+ let (p, c) = comm::stream();
759
759
760
- do task::spawn || {
760
+ do task::spawn {
761
761
do arc2.write |num| {
762
762
do 10.times {
763
763
let tmp = *num;
@@ -772,7 +772,7 @@ mod tests {
772
772
// Readers try to catch the writer in the act
773
773
let mut children = ~[];
774
774
do 5.times {
775
- let arc3 = (* arc) .clone();
775
+ let arc3 = arc.clone();
776
776
let mut builder = task::task();
777
777
builder.future_result(|r| children.push(r));
778
778
do builder.spawn {
@@ -801,15 +801,15 @@ mod tests {
801
801
// (4) tells writer and all other readers to contend as it downgrades.
802
802
// (5) Writer attempts to set state back to 42, while downgraded task
803
803
// and all reader tasks assert that it's 31337.
804
- let arc = ~ RWArc::new(0);
804
+ let arc = RWArc::new(0);
805
805
806
806
// Reader tasks
807
807
let mut reader_convos = ~[];
808
808
do 10.times {
809
- let ((rp1,rc1),(rp2,rc2)) = (comm::stream(),comm::stream());
809
+ let ((rp1, rc1), (rp2, rc2)) = (comm::stream(), comm::stream());
810
810
reader_convos.push((rc1, rp2));
811
- let arcn = (* arc) .clone();
812
- do task::spawn || {
811
+ let arcn = arc.clone();
812
+ do task::spawn {
813
813
rp1.recv(); // wait for downgrader to give go-ahead
814
814
do arcn.read |state| {
815
815
assert_eq!(*state, 31337);
@@ -819,8 +819,8 @@ mod tests {
819
819
}
820
820
821
821
// Writer task
822
- let arc2 = (* arc) .clone();
823
- let ((wp1,wc1),(wp2,wc2)) = (comm::stream(),comm::stream());
822
+ let arc2 = arc.clone();
823
+ let ((wp1, wc1), (wp2, wc2)) = (comm::stream(), comm::stream());
824
824
do task::spawn || {
825
825
wp1.recv();
826
826
do arc2.write_cond |state, cond| {
@@ -853,7 +853,7 @@ mod tests {
853
853
}
854
854
}
855
855
let read_mode = arc.downgrade(write_mode);
856
- do (& read_mode) .read |state| {
856
+ do read_mode.read |state| {
857
857
// complete handshake with other readers
858
858
for &(_, ref rp) in reader_convos.iter() {
859
859
rp.recv()
@@ -876,11 +876,11 @@ mod tests {
876
876
// line in RWLock::write_cond() that looks like:
877
877
// " blk( & Condvar { order: opt_lock, ..* cond } ) "
878
878
// with just " blk( cond) ".
879
- let x = ~ RWArc::new(true);
879
+ let x = RWArc::new(true);
880
880
let (wp, wc) = comm::stream();
881
881
882
882
// writer task
883
- let xw = (*x) .clone();
883
+ let xw = x .clone();
884
884
do task::spawn {
885
885
do xw.write_cond |state, c| {
886
886
wc.send(()); // tell downgrader it's ok to go
@@ -901,7 +901,7 @@ mod tests {
901
901
c.signal();
902
902
}
903
903
// make a reader task to trigger the " reader cloud lock" handoff
904
- let xr = (*x) .clone();
904
+ let xr = x .clone();
905
905
let (rp, rc) = comm::stream();
906
906
do task::spawn {
907
907
rc.send(());
0 commit comments