Skip to content

Commit 818ebf2

Browse files
committed
std::rt: Fix the set up of the main thread so that it doesn't try to steal 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.
1 parent c6e3501 commit 818ebf2

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)