File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -563,11 +563,10 @@ impl Scheduler {
563
563
// run the cleanup job, as expected by the previously called
564
564
// swap_contexts function.
565
565
unsafe {
566
- let sched = Local :: unsafe_borrow :: < Scheduler > ( ) ;
567
- ( * sched) . run_cleanup_job ( ) ;
566
+ let task = Local :: unsafe_borrow :: < Task > ( ) ;
567
+ ( * task ) . sched . get_mut_ref ( ) . run_cleanup_job ( ) ;
568
568
569
569
// Must happen after running the cleanup job (of course).
570
- let task = Local :: unsafe_borrow :: < Task > ( ) ;
571
570
( * task) . death . check_killed ( ( * task) . unwinder . unwinding ) ;
572
571
}
573
572
}
Original file line number Diff line number Diff line change @@ -281,20 +281,24 @@ impl<T> Drop for UnsafeAtomicRcBox<T>{
281
281
*/
282
282
// FIXME(#8140) should not be pub
283
283
pub unsafe fn atomically < U > ( f : & fn ( ) -> U ) -> U {
284
- use rt:: task:: Task ;
284
+ use rt:: task:: { Task , GreenTask , SchedTask } ;
285
285
use rt:: local:: Local ;
286
- use rt:: in_green_task_context;
287
-
288
- if in_green_task_context ( ) {
289
- let t = Local :: unsafe_borrow :: < Task > ( ) ;
290
- do ( || {
291
- ( * t) . death . inhibit_deschedule ( ) ;
292
- f ( )
293
- } ) . finally {
294
- ( * t) . death . allow_deschedule ( ) ;
286
+
287
+ match Local :: try_unsafe_borrow :: < Task > ( ) {
288
+ Some ( t) => {
289
+ match ( * t) . task_type {
290
+ GreenTask ( _) => {
291
+ do ( || {
292
+ ( * t) . death . inhibit_deschedule ( ) ;
293
+ f ( )
294
+ } ) . finally {
295
+ ( * t) . death . allow_deschedule ( ) ;
296
+ }
297
+ }
298
+ SchedTask => f ( )
299
+ }
295
300
}
296
- } else {
297
- f ( )
301
+ None => f ( )
298
302
}
299
303
}
300
304
You can’t perform that action at this time.
0 commit comments