From f59fcd5d5f7ba94f7c705eb2c081760dd2213067 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 19 May 2013 14:05:20 -0700 Subject: [PATCH] core::rt: Store Task as a ~ pointer --- src/libcore/rt/sched.rs | 6 +++--- src/libcore/rt/task.rs | 4 ++-- src/libcore/rt/test.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs index 4b2165b4d2ae..3abbb1f79e59 100644 --- a/src/libcore/rt/sched.rs +++ b/src/libcore/rt/sched.rs @@ -350,16 +350,16 @@ pub struct Coroutine { /// the task is dead priv saved_context: Context, /// The heap, GC, unwinding, local storage, logging - task: Task + task: ~Task } pub impl Coroutine { fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine { - Coroutine::with_task(stack_pool, Task::new(), start) + Coroutine::with_task(stack_pool, ~Task::new(), start) } fn with_task(stack_pool: &mut StackPool, - task: Task, + task: ~Task, start: ~fn()) -> Coroutine { let start = Coroutine::build_start_wrapper(start); let mut stack = stack_pool.take_segment(MIN_STACK_SIZE); diff --git a/src/libcore/rt/task.rs b/src/libcore/rt/task.rs index c3832d1338ad..65b7c885b573 100644 --- a/src/libcore/rt/task.rs +++ b/src/libcore/rt/task.rs @@ -155,7 +155,7 @@ pub fn borrow_local_task(f: &fn(&mut Task)) { do local_sched::borrow |sched| { match sched.current_task { Some(~ref mut task) => { - f(&mut task.task) + f(&mut *task.task) } None => { fail!("no local services for schedulers yet") @@ -167,7 +167,7 @@ pub fn borrow_local_task(f: &fn(&mut Task)) { pub unsafe fn unsafe_borrow_local_task() -> *mut Task { match (*local_sched::unsafe_borrow()).current_task { Some(~ref mut task) => { - let s: *mut Task = &mut task.task; + let s: *mut Task = &mut *task.task; return s; } None => { diff --git a/src/libcore/rt/test.rs b/src/libcore/rt/test.rs index c3e52594d6e7..66993041752c 100644 --- a/src/libcore/rt/test.rs +++ b/src/libcore/rt/test.rs @@ -29,7 +29,7 @@ pub fn run_in_newsched_task(f: ~fn()) { do run_in_bare_thread { let mut sched = ~UvEventLoop::new_scheduler(); let task = ~Coroutine::with_task(&mut sched.stack_pool, - Task::without_unwinding(), + ~Task::without_unwinding(), f.take()); sched.enqueue_task(task); sched.run(); @@ -42,7 +42,7 @@ pub fn spawntask(f: ~fn()) { let mut sched = local_sched::take(); let task = ~Coroutine::with_task(&mut sched.stack_pool, - Task::without_unwinding(), + ~Task::without_unwinding(), f); do sched.switch_running_tasks_and_then(task) |task| { let task = Cell(task); @@ -57,7 +57,7 @@ pub fn spawntask_immediately(f: ~fn()) { let mut sched = local_sched::take(); let task = ~Coroutine::with_task(&mut sched.stack_pool, - Task::without_unwinding(), + ~Task::without_unwinding(), f); do sched.switch_running_tasks_and_then(task) |task| { let task = Cell(task); @@ -73,7 +73,7 @@ pub fn spawntask_later(f: ~fn()) { let mut sched = local_sched::take(); let task = ~Coroutine::with_task(&mut sched.stack_pool, - Task::without_unwinding(), + ~Task::without_unwinding(), f); sched.enqueue_task(task); @@ -90,7 +90,7 @@ pub fn spawntask_random(f: ~fn()) { let mut sched = local_sched::take(); let task = ~Coroutine::with_task(&mut sched.stack_pool, - Task::without_unwinding(), + ~Task::without_unwinding(), f); if run_now { @@ -156,7 +156,7 @@ pub fn spawntask_thread(f: ~fn()) -> Thread { let thread = do Thread::start { let mut sched = ~UvEventLoop::new_scheduler(); let task = ~Coroutine::with_task(&mut sched.stack_pool, - Task::without_unwinding(), + ~Task::without_unwinding(), f.take()); sched.enqueue_task(task); sched.run();