diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-08-10 18:48:57 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-08-15 09:26:51 -0700 |
| commit | b2dad8af31d5d77e9e7da8561d87249fff216e80 (patch) | |
| tree | 29e255b492c44064e8e96a1375cfc3d240776013 /src/rt/rust_task.cpp | |
| parent | 871d1317e51fce142def29b7bde9dcb1225050bf (diff) | |
| download | rust-b2dad8af31d5d77e9e7da8561d87249fff216e80.tar.gz rust-b2dad8af31d5d77e9e7da8561d87249fff216e80.zip | |
Added a library version of spawn. Before long, we can remove the old version.
Diffstat (limited to 'src/rt/rust_task.cpp')
| -rw-r--r-- | src/rt/rust_task.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
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(); |
