@@ -1416,7 +1416,8 @@ mod test {
1416
1416
1417
1417
#[ test]
1418
1418
fn test_spawn_sched_blocking ( ) {
1419
- use std:: unstable:: mutex:: Mutex ;
1419
+ use std:: unstable:: mutex:: { Mutex , MUTEX_INIT } ;
1420
+ static mut LOCK : Mutex = MUTEX_INIT ;
1420
1421
1421
1422
// Testing that a task in one scheduler can block in foreign code
1422
1423
// without affecting other schedulers
@@ -1425,19 +1426,15 @@ mod test {
1425
1426
let ( start_po, start_ch) = Chan :: new ( ) ;
1426
1427
let ( fin_po, fin_ch) = Chan :: new ( ) ;
1427
1428
1428
- let lock = unsafe { Mutex :: new ( ) } ;
1429
- let lock2 = unsafe { lock. clone ( ) } ;
1430
-
1431
1429
let mut handle = pool. spawn_sched ( ) ;
1432
1430
handle. send ( PinnedTask ( pool. task ( TaskOpts :: new ( ) , proc ( ) {
1433
- let mut lock = lock2;
1434
1431
unsafe {
1435
- lock . lock ( ) ;
1432
+ LOCK . lock ( ) ;
1436
1433
1437
1434
start_ch. send ( ( ) ) ;
1438
- lock . wait ( ) ; // block the scheduler thread
1439
- lock . signal ( ) ; // let them know we have the lock
1440
- lock . unlock ( ) ;
1435
+ LOCK . wait ( ) ; // block the scheduler thread
1436
+ LOCK . signal ( ) ; // let them know we have the lock
1437
+ LOCK . unlock ( ) ;
1441
1438
}
1442
1439
1443
1440
fin_ch. send ( ( ) ) ;
@@ -1469,12 +1466,11 @@ mod test {
1469
1466
child_ch. send ( 20 ) ;
1470
1467
pingpong ( & parent_po, & child_ch) ;
1471
1468
unsafe {
1472
- let mut lock = lock;
1473
- lock. lock ( ) ;
1474
- lock. signal ( ) ; // wakeup waiting scheduler
1475
- lock. wait ( ) ; // wait for them to grab the lock
1476
- lock. unlock ( ) ;
1477
- lock. destroy ( ) ; // now we're guaranteed they have no locks
1469
+ LOCK . lock ( ) ;
1470
+ LOCK . signal ( ) ; // wakeup waiting scheduler
1471
+ LOCK . wait ( ) ; // wait for them to grab the lock
1472
+ LOCK . unlock ( ) ;
1473
+ LOCK . destroy ( ) ; // now we're guaranteed they have no locks
1478
1474
}
1479
1475
} ) ) ) ;
1480
1476
drop ( handle) ;
0 commit comments