core::rt: Store Task as a ~ pointer

This commit is contained in:
Brian Anderson 2013-05-19 14:05:20 -07:00
parent 43c6f32ece
commit f59fcd5d5f
3 changed files with 11 additions and 11 deletions

View File

@ -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);

View File

@ -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 => {

View File

@ -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();