From b2dad8af31d5d77e9e7da8561d87249fff216e80 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 10 Aug 2011 18:48:57 -0700 Subject: Added a library version of spawn. Before long, we can remove the old version. --- src/rt/rust_task.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 26ffcb307a5..a03388a2a55 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -52,13 +52,6 @@ del_stk(rust_task *task, stk_seg *stk) } // Tasks - -// FIXME (issue #31): ifdef by platform. This is getting absurdly -// x86-specific. - -size_t const n_callee_saves = 4; -size_t const callee_save_fp = 0; - rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, rust_task *spawner, const char *name) : ref_count(1), @@ -115,15 +108,8 @@ struct spawn_args { }; extern "C" CDECL -void task_start_wrapper(spawn_args *a) -{ - rust_task *task = a->task; - int rval = 42; - - a->f(&rval, task, a->a3, a->a4); - +void task_exit(void *env, int rval, rust_task *task) { LOG(task, task, "task exited with value %d", rval); - task->die(); task->lock.lock(); task->notify_tasks_waiting_to_join(); @@ -132,6 +118,16 @@ void task_start_wrapper(spawn_args *a) task->yield(1); } +extern "C" CDECL +void task_start_wrapper(spawn_args *a) +{ + rust_task *task = a->task; + int rval = 42; + + a->f(&rval, task, a->a3, a->a4); + task_exit(NULL, rval, task); +} + void rust_task::start(uintptr_t spawnee_fn, uintptr_t args) @@ -154,6 +150,11 @@ rust_task::start(uintptr_t spawnee_fn, ctx.call((void *)task_start_wrapper, a, sp); + this->start(); +} + +void rust_task::start() +{ yield_timer.reset_us(0); transition(&sched->newborn_tasks, &sched->running_tasks); sched->lock.signal(); -- cgit 1.4.1-3-g733a5