about summary refs log tree commit diff
path: root/src/libstd/task/spawn.rs
diff options
context:
space:
mode:
authortoddaaro <github@opprobrio.us>2013-08-05 13:06:24 -0700
committertoddaaro <github@opprobrio.us>2013-08-08 14:13:41 -0700
commitaf2e03998d4d06f2781ca72ec005f6913148f8bb (patch)
treefc65de2220eb4735ef6fdf554b5c7204ec41d6b1 /src/libstd/task/spawn.rs
parenta0080f4e07891c89aa1f9851f8b0a3c754734fe8 (diff)
downloadrust-af2e03998d4d06f2781ca72ec005f6913148f8bb.tar.gz
rust-af2e03998d4d06f2781ca72ec005f6913148f8bb.zip
Enabled workstealing in the scheduler. Previously we had one global work queue shared by each scheduler. Now there is a separate work queue for each scheduler, and work is "stolen" from other queues when it is exhausted locally.
Diffstat (limited to 'src/libstd/task/spawn.rs')
-rw-r--r--src/libstd/task/spawn.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 2d0a2d98e9f..05a17f8539c 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -98,6 +98,7 @@ use rt::kill::KillHandle;
 use rt::sched::Scheduler;
 use rt::uv::uvio::UvEventLoop;
 use rt::thread::Thread;
+use rt::work_queue::WorkQueue;
 
 #[cfg(test)] use task::default_task_opts;
 #[cfg(test)] use comm;
@@ -722,10 +723,16 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) {
             let sched = Local::unsafe_borrow::<Scheduler>();
             let sched_handle = (*sched).make_handle();
 
+            // Since this is a 1:1 scheduler we create a queue not in
+            // the stealee set. The run_anything flag is set false
+            // which will disable stealing.
+            let work_queue = WorkQueue::new();
+
             // Create a new scheduler to hold the new task
             let new_loop = ~UvEventLoop::new();
             let mut new_sched = ~Scheduler::new_special(new_loop,
-                                                        (*sched).work_queue.clone(),
+                                                        work_queue,
+                                                        (*sched).work_queues.clone(),
                                                         (*sched).sleeper_list.clone(),
                                                         false,
                                                         Some(sched_handle));