diff options
| author | unknown <Eric@.(none)> | 2011-08-08 13:38:20 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-08-08 16:55:38 -0700 |
| commit | 44bef5f2cb175769155d92ec65bd6b16e6708a1e (patch) | |
| tree | d7524b51e2af0cb191cd93cda3f282ac4ac8f4c6 /src/rt/rust_upcall.cpp | |
| parent | f4f057ced1f4152575571a6e5116e1ad5bb38beb (diff) | |
| download | rust-44bef5f2cb175769155d92ec65bd6b16e6708a1e.tar.gz rust-44bef5f2cb175769155d92ec65bd6b16e6708a1e.zip | |
Introduced task handles.
This is the new way to refer to tasks in rust-land. Currently all they do is serve as a key to look up the old rust_task structure. Ideally they won't be ref counted, but baby steps.
Diffstat (limited to 'src/rt/rust_upcall.cpp')
| -rw-r--r-- | src/rt/rust_upcall.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 2190ec7b49f..5feffe600c3 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -140,9 +140,11 @@ void upcall_del_chan(rust_task *task, rust_chan *chan) { * has its own copy of the channel. */ extern "C" CDECL rust_chan * -upcall_clone_chan(rust_task *task, rust_task *target, +upcall_clone_chan(rust_task *task, rust_task_id tid, rust_chan *chan) { + // FIXME: This should be removed. LOG_UPCALL_ENTRY(task); + rust_task *target = task->kernel->get_task_by_id(tid); return chan->clone(target); } @@ -203,9 +205,9 @@ upcall_fail(rust_task *task, * Called whenever a task's ref count drops to zero. */ extern "C" CDECL void -upcall_kill(rust_task *task, rust_task *target) { +upcall_kill(rust_task *task, rust_task_id tid) { LOG_UPCALL_ENTRY(task); - + rust_task *target = task->kernel->get_task_by_id(tid); target->kill(); } @@ -322,9 +324,9 @@ upcall_new_str(rust_task *task, char const *s, size_t fill) { } extern "C" CDECL rust_str * -upcall_dup_str(rust_task *task, rust_task *target, rust_str *str) { +upcall_dup_str(rust_task *task, rust_task_id tid, rust_str *str) { LOG_UPCALL_ENTRY(task); - + rust_task *target = task->kernel->get_task_by_id(tid); return make_str(target, (char const *)str->data, str->fill); } @@ -482,27 +484,30 @@ upcall_get_type_desc(rust_task *task, return td; } -extern "C" CDECL rust_task * +extern "C" CDECL rust_task_id upcall_new_task(rust_task *spawner, rust_vec *name) { // name is a rust string structure. LOG_UPCALL_ENTRY(spawner); - rust_task *task = + rust_task_id tid = spawner->kernel->create_task(spawner, (const char *)name->data); + rust_task *task = spawner->kernel->get_task_by_id(tid); task->ref(); - return task; + return tid; } extern "C" CDECL void -upcall_take_task(rust_task *task, rust_task *target) { +upcall_take_task(rust_task *task, rust_task_id tid) { LOG_UPCALL_ENTRY(task); + rust_task *target = task->kernel->get_task_by_id(tid); if(target) { target->ref(); } } extern "C" CDECL void -upcall_drop_task(rust_task *task, rust_task *target) { +upcall_drop_task(rust_task *task, rust_task_id tid) { LOG_UPCALL_ENTRY(task); + rust_task *target = task->kernel->get_task_by_id(tid); if(target) { target->deref(); } @@ -526,13 +531,14 @@ upcall_drop_chan(rust_task *task, rust_chan *target) { extern "C" CDECL rust_task * upcall_start_task(rust_task *spawner, - rust_task *task, + rust_task_id tid, uintptr_t spawnee_fn, uintptr_t args, size_t args_sz) { LOG_UPCALL_ENTRY(spawner); rust_scheduler *sched = spawner->sched; + rust_task *task = spawner->kernel->get_task_by_id(tid); DLOG(sched, task, "upcall start_task(task %s @0x%" PRIxPTR ", spawnee 0x%" PRIxPTR ")", |
