Skip to content

Commit fabec99

Browse files
committed
auto merge of #9857 : brson/rust/mainsched, r=alexcrichton
...al work This is causing really awful scheduler behavior where the main thread scheduler is continually waking up, stealing work, discovering it can't actually run the work, and sending it off to another scheduler. No test cases because we don't have suitable instrumentation for it.
2 parents 3d75ec5 + 818ebf2 commit fabec99

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/libstd/rt/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,14 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
310310
sleepers.clone(),
311311
false,
312312
Some(friend_handle));
313-
let main_handle = main_sched.make_handle();
314-
handles.push(main_handle);
313+
let mut main_handle = main_sched.make_handle();
314+
// Allow the scheduler to exit when the main task exits.
315+
// Note: sending the shutdown message also prevents the scheduler
316+
// from pushing itself to the sleeper list, which is used for
317+
// waking up schedulers for work stealing; since this is a
318+
// non-work-stealing scheduler it should not be adding itself
319+
// to the list.
320+
main_handle.send_shutdown();
315321
Some(main_sched)
316322
} else {
317323
None

0 commit comments

Comments
 (0)