@@ -91,7 +91,7 @@ use to_bytes::IterBytes;
91
91
use uint;
92
92
use util;
93
93
use unstable:: sync:: Exclusive ;
94
- use rt:: { OldTaskContext , TaskContext , SchedulerContext , GlobalContext , context } ;
94
+ use rt:: { OldTaskContext , NewRtContext , context , in_green_task_context } ;
95
95
use rt:: local:: Local ;
96
96
use rt:: task:: { Task , Sched } ;
97
97
use rt:: kill:: KillHandle ;
@@ -526,7 +526,7 @@ impl RuntimeGlue {
526
526
let me = rt:: rust_get_task ( ) ;
527
527
blk ( OldTask ( me) , rt:: rust_task_is_unwinding ( me) )
528
528
} ,
529
- TaskContext => unsafe {
529
+ NewRtContext if in_green_task_context ( ) => unsafe {
530
530
// Can't use safe borrow, because the taskgroup destructor needs to
531
531
// access the scheduler again to send kill signals to other tasks.
532
532
let me = Local :: unsafe_borrow :: < Task > ( ) ;
@@ -535,7 +535,7 @@ impl RuntimeGlue {
535
535
blk ( NewTask ( ( * me) . death . kill_handle . get_ref ( ) . clone ( ) ) ,
536
536
( * me) . unwinder . unwinding )
537
537
} ,
538
- SchedulerContext | GlobalContext => rtabort ! ( "task dying in bad context" ) ,
538
+ NewRtContext => rtabort ! ( "task dying in bad context" ) ,
539
539
}
540
540
}
541
541
@@ -563,7 +563,7 @@ impl RuntimeGlue {
563
563
}
564
564
}
565
565
} ,
566
- TaskContext => unsafe {
566
+ NewRtContext if in_green_task_context ( ) => unsafe {
567
567
// Can't use safe borrow, because creating new hashmaps for the
568
568
// tasksets requires an rng, which needs to borrow the sched.
569
569
let me = Local :: unsafe_borrow :: < Task > ( ) ;
@@ -588,7 +588,7 @@ impl RuntimeGlue {
588
588
Some ( ref group) => group,
589
589
} )
590
590
} ,
591
- SchedulerContext | GlobalContext => rtabort ! ( "spawning in bad context" ) ,
591
+ NewRtContext => rtabort ! ( "spawning in bad context" ) ,
592
592
}
593
593
}
594
594
}
@@ -666,10 +666,9 @@ fn enlist_many(child: TaskHandle, child_arc: &TaskGroupArc,
666
666
667
667
pub fn spawn_raw ( opts : TaskOpts , f : ~fn ( ) ) {
668
668
match context ( ) {
669
- OldTaskContext => spawn_raw_oldsched ( opts, f) ,
670
- TaskContext => spawn_raw_newsched ( opts, f) ,
671
- SchedulerContext => fail ! ( "can't spawn from scheduler context" ) ,
672
- GlobalContext => fail ! ( "can't spawn from global context" ) ,
669
+ OldTaskContext => spawn_raw_oldsched ( opts, f) ,
670
+ _ if in_green_task_context ( ) => spawn_raw_newsched ( opts, f) ,
671
+ _ => fail ! ( "can't spawn from this context" )
673
672
}
674
673
}
675
674
0 commit comments