@@ -91,7 +91,7 @@ use to_bytes::IterBytes;
9191use  uint; 
9292use  util; 
9393use  unstable:: sync:: Exclusive ; 
94- use  rt:: { OldTaskContext ,  TaskContext ,   SchedulerContext ,   GlobalContext ,  context } ; 
94+ use  rt:: { OldTaskContext ,  NewRtContext ,  context ,  in_green_task_context } ; 
9595use  rt:: local:: Local ; 
9696use  rt:: task:: { Task ,  Sched } ; 
9797use  rt:: kill:: KillHandle ; 
@@ -526,7 +526,7 @@ impl RuntimeGlue {
526526                let  me = rt:: rust_get_task ( ) ; 
527527                blk ( OldTask ( me) ,  rt:: rust_task_is_unwinding ( me) ) 
528528            } , 
529-             TaskContext  => unsafe  { 
529+             NewRtContext   if   in_green_task_context ( )  => unsafe  { 
530530                // Can't use safe borrow, because the taskgroup destructor needs to 
531531                // access the scheduler again to send kill signals to other tasks. 
532532                let  me = Local :: unsafe_borrow :: < Task > ( ) ; 
@@ -535,7 +535,7 @@ impl RuntimeGlue {
535535                blk ( NewTask ( ( * me) . death . kill_handle . get_ref ( ) . clone ( ) ) , 
536536                    ( * me) . unwinder . unwinding ) 
537537            } , 
538-             SchedulerContext  |  GlobalContext  => rtabort ! ( "task dying in bad context" ) , 
538+             NewRtContext  => rtabort ! ( "task dying in bad context" ) , 
539539        } 
540540    } 
541541
@@ -563,7 +563,7 @@ impl RuntimeGlue {
563563                    } 
564564                } 
565565            } , 
566-             TaskContext  => unsafe  { 
566+             NewRtContext   if   in_green_task_context ( )  => unsafe  { 
567567                // Can't use safe borrow, because creating new hashmaps for the 
568568                // tasksets requires an rng, which needs to borrow the sched. 
569569                let  me = Local :: unsafe_borrow :: < Task > ( ) ; 
@@ -588,7 +588,7 @@ impl RuntimeGlue {
588588                    Some ( ref  group)  => group, 
589589                } ) 
590590            } , 
591-             SchedulerContext  |  GlobalContext  => rtabort ! ( "spawning in bad context" ) , 
591+             NewRtContext  => rtabort ! ( "spawning in bad context" ) , 
592592        } 
593593    } 
594594} 
@@ -666,10 +666,9 @@ fn enlist_many(child: TaskHandle, child_arc: &TaskGroupArc,
666666
667667pub  fn  spawn_raw ( opts :  TaskOpts ,  f :  ~fn ( ) )  { 
668668    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" ) 
673672    } 
674673} 
675674
0 commit comments