diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-08-08 19:27:03 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-08-08 19:27:03 -0700 |
| commit | 56730c094cf95be58fb05b0e423673aca2a98b88 (patch) | |
| tree | 096a652b16d38a6f4ff65dd39657ccf308249909 /src/libstd/task | |
| parent | 03cc757fe90b88895fcf911d9cce5c04a008b127 (diff) | |
| parent | 936f70bd878327d867b6f8f82061d738355a47c9 (diff) | |
| download | rust-56730c094cf95be58fb05b0e423673aca2a98b88.tar.gz rust-56730c094cf95be58fb05b0e423673aca2a98b88.zip | |
Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/mod.rs | 31 | ||||
| -rw-r--r-- | src/libstd/task/spawn.rs | 29 |
2 files changed, 45 insertions, 15 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 225a4b8cfd2..2e0c9c1d1ad 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -142,7 +142,8 @@ pub struct TaskOpts { indestructible: bool, notify_chan: Option<Chan<TaskResult>>, name: Option<~str>, - sched: SchedOpts + sched: SchedOpts, + stack_size: Option<uint> } /** @@ -197,7 +198,8 @@ impl TaskBuilder { indestructible: self.opts.indestructible, notify_chan: notify_chan, name: name, - sched: self.opts.sched + sched: self.opts.sched, + stack_size: self.opts.stack_size }, gen_body: gen_body, can_not_copy: None, @@ -351,7 +353,8 @@ impl TaskBuilder { indestructible: x.opts.indestructible, notify_chan: notify_chan, name: name, - sched: x.opts.sched + sched: x.opts.sched, + stack_size: x.opts.stack_size }; let f = match gen_body { Some(gen) => { @@ -422,7 +425,8 @@ pub fn default_task_opts() -> TaskOpts { name: None, sched: SchedOpts { mode: DefaultScheduler, - } + }, + stack_size: None } } @@ -655,6 +659,7 @@ pub unsafe fn rekillable<U>(f: &fn() -> U) -> U { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_kill_unkillable_task() { use rt::test::*; @@ -675,6 +680,7 @@ fn test_kill_unkillable_task() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_kill_rekillable_task() { use rt::test::*; @@ -716,6 +722,7 @@ fn test_cant_dup_task_builder() { #[cfg(test)] fn block_forever() { let (po, _ch) = stream::<()>(); po.recv(); } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port use rt::test::run_in_newsched_task; @@ -734,6 +741,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port po.recv(); } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails use rt::test::run_in_newsched_task; @@ -741,6 +749,7 @@ fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails do spawn_unlinked { fail!(); } } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails use rt::test::run_in_newsched_task; @@ -750,6 +759,7 @@ fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails do 16.times { task::yield(); } } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_fail_down() { use rt::test::run_in_newsched_task; @@ -762,6 +772,7 @@ fn test_spawn_unlinked_sup_fail_down() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_linked_sup_fail_up() { // child fails; parent fails use rt::test::run_in_newsched_task; @@ -782,6 +793,7 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails assert!(result.is_err()); } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_linked_sup_fail_down() { // parent fails; child fails use rt::test::run_in_newsched_task; @@ -798,6 +810,7 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails assert!(result.is_err()); } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails use rt::test::run_in_newsched_task; @@ -810,6 +823,7 @@ fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails assert!(result.is_err()); } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails use rt::test::run_in_newsched_task; @@ -822,6 +836,7 @@ fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails assert!(result.is_err()); } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails use rt::test::run_in_newsched_task; @@ -840,6 +855,7 @@ fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails // A couple bonus linked failure tests - testing for failure propagation even // when the middle task exits successfully early before kill signals are sent. +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_failure_propagate_grandchild() { use rt::test::run_in_newsched_task; @@ -856,6 +872,7 @@ fn test_spawn_failure_propagate_grandchild() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_failure_propagate_secondborn() { use rt::test::run_in_newsched_task; @@ -872,6 +889,7 @@ fn test_spawn_failure_propagate_secondborn() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_failure_propagate_nephew_or_niece() { use rt::test::run_in_newsched_task; @@ -888,6 +906,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_linked_sup_propagate_sibling() { use rt::test::run_in_newsched_task; @@ -1191,6 +1210,7 @@ fn test_avoid_copying_the_body_unlinked() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] #[should_fail] @@ -1226,6 +1246,7 @@ fn test_unkillable() { po.recv(); } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] #[should_fail] @@ -1292,6 +1313,7 @@ fn test_simple_newsched_spawn() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_spawn_watched() { use rt::test::run_in_newsched_task; @@ -1314,6 +1336,7 @@ fn test_spawn_watched() { } } +#[ignore(reason = "linked failure")] #[test] #[ignore(cfg(windows))] fn test_indestructible() { use rt::test::run_in_newsched_task; diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 527b20b0e90..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; @@ -500,7 +501,7 @@ impl RuntimeGlue { OldTask(ptr) => rt::rust_task_kill_other(ptr), NewTask(handle) => { let mut handle = handle; - do handle.kill().map_consume |killed_task| { + do handle.kill().map_move |killed_task| { let killed_task = Cell::new(killed_task); do Local::borrow::<Scheduler, ()> |sched| { sched.enqueue_task(killed_task.take()); @@ -682,7 +683,7 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { // Child task runs this code. // If child data is 'None', the enlist is vacuously successful. - let enlist_success = do child_data.take().map_consume_default(true) |child_data| { + let enlist_success = do child_data.take().map_move_default(true) |child_data| { let child_data = Cell::new(child_data); // :( do Local::borrow::<Task, bool> |me| { let (child_tg, ancestors, is_main) = child_data.take(); @@ -713,19 +714,25 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { let mut task = unsafe { if opts.sched.mode != SingleThreaded { if opts.watched { - Task::build_child(child_wrapper) + Task::build_child(opts.stack_size, child_wrapper) } else { - Task::build_root(child_wrapper) + Task::build_root(opts.stack_size, child_wrapper) } } else { // Creating a 1:1 task:thread ... 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)); @@ -736,16 +743,16 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { // Pin the new task to the new scheduler let new_task = if opts.watched { - Task::build_homed_child(child_wrapper, Sched(new_sched_handle)) + Task::build_homed_child(opts.stack_size, child_wrapper, Sched(new_sched_handle)) } else { - Task::build_homed_root(child_wrapper, Sched(new_sched_handle)) + Task::build_homed_root(opts.stack_size, child_wrapper, Sched(new_sched_handle)) }; // Create a task that will later be used to join with the new scheduler // thread when it is ready to terminate let (thread_port, thread_chan) = oneshot(); let thread_port_cell = Cell::new(thread_port); - let join_task = do Task::build_child() { + let join_task = do Task::build_child(None) { rtdebug!("running join task"); let thread_port = thread_port_cell.take(); let thread: Thread = thread_port.recv(); @@ -762,8 +769,8 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { let mut orig_sched_handle = orig_sched_handle_cell.take(); let join_task = join_task_cell.take(); - let bootstrap_task = ~do Task::new_root(&mut new_sched.stack_pool) || { - rtdebug!("bootstrapping a 1:1 scheduler"); + let bootstrap_task = ~do Task::new_root(&mut new_sched.stack_pool, None) || { + rtdebug!("boostrapping a 1:1 scheduler"); }; new_sched.bootstrap(bootstrap_task); @@ -854,7 +861,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) { // Even if the below code fails to kick the child off, we must // send Something on the notify channel. - let notifier = notify_chan.map_consume(|c| AutoNotify(c)); + let notifier = notify_chan.map_move(|c| AutoNotify(c)); if enlist_many(OldTask(child), &child_arc, &mut ancestors) { let group = @@mut Taskgroup(child_arc, ancestors, is_main, notifier); |
