diff options
| author | toddaaro <github@opprobrio.us> | 2013-06-26 16:41:00 -0700 |
|---|---|---|
| committer | toddaaro <github@opprobrio.us> | 2013-07-01 16:14:56 -0700 |
| commit | 5cfad4b6de3a9ab749c975338c23fc2e20b0beec (patch) | |
| tree | 76891a17d34f8418a466429b7e121c3ebb4cd400 /src/libstd/task | |
| parent | e65d0cbabebc73f2c9733a7ed158576c9702e71e (diff) | |
| download | rust-5cfad4b6de3a9ab749c975338c23fc2e20b0beec.tar.gz rust-5cfad4b6de3a9ab749c975338c23fc2e20b0beec.zip | |
Refactored the runtime to view coroutines as a component of tasks, instead of tasks as a component of coroutines.
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/mod.rs | 1 | ||||
| -rw-r--r-- | src/libstd/task/spawn.rs | 27 |
2 files changed, 20 insertions, 8 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 99858feab22..b0fc6b2884f 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -1182,3 +1182,4 @@ fn test_simple_newsched_spawn() { spawn(||()) } } + diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 63eb768d1c9..aea8cda6a21 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -581,13 +581,20 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) { fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { use rt::sched::*; - let mut task = if opts.linked { - do Local::borrow::<Task, ~Task>() |running_task| { - ~running_task.new_child() + let f = Cell::new(f); + + let mut task = unsafe { + let sched = Local::unsafe_borrow::<Scheduler>(); + rtdebug!("unsafe borrowed sched"); + + if opts.linked { + do Local::borrow::<Task, ~Task>() |running_task| { + ~running_task.new_child(&mut (*sched).stack_pool, f.take()) + } + } else { + // An unlinked task is a new root in the task tree + ~Task::new_root(&mut (*sched).stack_pool, f.take()) } - } else { - // An unlinked task is a new root in the task tree - ~Task::new_root() }; if opts.notify_chan.is_some() { @@ -601,9 +608,13 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { task.on_exit = Some(on_exit); } + rtdebug!("spawn about to take scheduler"); + let mut sched = Local::take::<Scheduler>(); - let task = ~Coroutine::with_task(&mut sched.stack_pool, - task, f); + rtdebug!("took sched in spawn"); +// let task = ~Coroutine::with_task(&mut sched.stack_pool, +// task, f); +// let task = ~Task::new_root(&mut sched.stack_pool, f); sched.schedule_task(task); } |
