@@ -1720,9 +1720,16 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
1720
1720
// Unidirectional "parenting" shouldn't override bidirectional linked.
1721
1721
// We have to cheat with opts - the interface doesn't support them because
1722
1722
// they don't make sense (redundant with task().supervised()).
1723
+ let opts = {
1724
+ let mut opts = default_task_opts( ) ;
1725
+ opts. linked = true;
1726
+ opts. supervised = true;
1727
+ move opts
1728
+ } ;
1729
+
1723
1730
let b0 = task( ) ;
1724
1731
let b1 = TaskBuilder ( {
1725
- opts: { linked : true , supervised : true , .. b0 . opts } ,
1732
+ opts: move opts,
1726
1733
can_not_copy: None ,
1727
1734
.. * b0
1728
1735
} ) ;
@@ -1733,9 +1740,16 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
1733
1740
fn test_spawn_linked_sup_fail_down( ) { // parent fails; child fails
1734
1741
// We have to cheat with opts - the interface doesn't support them because
1735
1742
// they don't make sense (redundant with task().supervised()).
1743
+ let opts = {
1744
+ let mut opts = default_task_opts( ) ;
1745
+ opts. linked = true;
1746
+ opts. supervised = true;
1747
+ move opts
1748
+ } ;
1749
+
1736
1750
let b0 = task( ) ;
1737
1751
let b1 = TaskBuilder ( {
1738
- opts: { linked : true , supervised : true , .. b0 . opts } ,
1752
+ opts: move opts,
1739
1753
can_not_copy: None ,
1740
1754
.. * b0
1741
1755
} ) ;
@@ -1816,33 +1830,39 @@ fn test_spawn_linked_sup_propagate_sibling() {
1816
1830
1817
1831
#[ test]
1818
1832
#[ ignore( cfg( windows) ) ]
1819
- fn test_spawn_raw_notify( ) {
1820
- let task_po = comm:: Port ( ) ;
1821
- let task_ch = comm:: Chan ( task_po) ;
1822
- let notify_po = comm:: Port ( ) ;
1823
- let notify_ch = comm:: Chan ( notify_po) ;
1833
+ fn test_spawn_raw_notify_success( ) {
1834
+ let ( task_ch, task_po) = pipes:: stream( ) ;
1835
+ let ( notify_ch, notify_po) = pipes:: stream( ) ;
1824
1836
1825
1837
let opts = {
1826
- notify_chan: Some ( notify_ch) ,
1838
+ notify_chan: Some ( move notify_ch)
1827
1839
.. default_task_opts( )
1828
1840
} ;
1829
- do spawn_raw( opts) {
1830
- comm :: send( task_ch , get_task( ) ) ;
1841
+ do spawn_raw( opts) |move task_ch| {
1842
+ task_ch . send( get_task( ) ) ;
1831
1843
}
1832
- let task_ = comm:: recv( task_po) ;
1833
- assert comm:: recv( notify_po) == Exit ( task_, Success ) ;
1844
+ let task_ = task_po. recv( ) ;
1845
+ assert notify_po. recv( ) == Exit ( task_, Success ) ;
1846
+ }
1847
+
1848
+ #[ test]
1849
+ #[ ignore( cfg( windows) ) ]
1850
+ fn test_spawn_raw_notify_failure( ) {
1851
+ // New bindings for these
1852
+ let ( task_ch, task_po) = pipes:: stream( ) ;
1853
+ let ( notify_ch, notify_po) = pipes:: stream( ) ;
1834
1854
1835
1855
let opts = {
1836
1856
linked: false,
1837
1857
notify_chan: Some ( notify_ch) ,
1838
1858
.. default_task_opts( )
1839
1859
} ;
1840
1860
do spawn_raw( opts) {
1841
- comm :: send( task_ch , get_task( ) ) ;
1861
+ task_ch . send( get_task( ) ) ;
1842
1862
fail;
1843
1863
}
1844
- let task_ = comm :: recv( task_po ) ;
1845
- assert comm :: recv( notify_po ) == Exit ( task_, Failure ) ;
1864
+ let task_ = task_po . recv( ) ;
1865
+ assert notify_po . recv( ) == Exit ( task_, Failure ) ;
1846
1866
}
1847
1867
1848
1868
#[ test]
@@ -2140,8 +2160,13 @@ fn test_unkillable() {
2140
2160
let po = comm::Port();
2141
2161
let ch = po.chan();
2142
2162
2163
+ let opts = {
2164
+ let mut opts = default_task_opts();
2165
+ opts.linked = false;
2166
+ move opts
2167
+ };
2143
2168
// We want to do this after failing
2144
- do spawn_raw({ linked: false,.. default_task_opts() } ) {
2169
+ do spawn_raw(opts ) {
2145
2170
for iter::repeat(10u) { yield() }
2146
2171
ch.send(());
2147
2172
}
@@ -2173,11 +2198,15 @@ fn test_unkillable() {
2173
2198
#[ignore(cfg(windows))]
2174
2199
#[should_fail]
2175
2200
fn test_unkillable_nested() {
2176
- let po = comm::Port();
2177
- let ch = po.chan();
2201
+ let (ch, po) = pipes::stream();
2178
2202
2179
2203
// We want to do this after failing
2180
- do spawn_raw({ linked: false,.. default_task_opts() }) {
2204
+ let opts = {
2205
+ let mut opts = default_task_opts();
2206
+ opts.linked = false;
2207
+ move opts
2208
+ };
2209
+ do spawn_raw(opts) {
2181
2210
for iter::repeat(10u) { yield() }
2182
2211
ch.send(());
2183
2212
}
0 commit comments