summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/task.rs16
-rw-r--r--src/rt/rust.cpp5
-rw-r--r--src/rt/rust_builtin.cpp18
-rw-r--r--src/rt/rust_scheduler.cpp4
-rw-r--r--src/rt/rust_scheduler.h8
-rw-r--r--src/rt/rust_task_thread.cpp6
-rw-r--r--src/rt/rust_task_thread.h4
7 files changed, 24 insertions, 37 deletions
diff --git a/src/libcore/task.rs b/src/libcore/task.rs
index c673fbf9b84..90208475d9c 100644
--- a/src/libcore/task.rs
+++ b/src/libcore/task.rs
@@ -487,7 +487,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
     let fptr = ptr::addr_of(f);
     let closure: *rust_closure = unsafe::reinterpret_cast(fptr);
 
-    let task_id = alt opts.sched {
+    let new_task = alt opts.sched {
       none {
         rustrt::new_task()
       }
@@ -498,13 +498,13 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
 
     option::may(opts.notify_chan) {|c|
         // FIXME (1087): Would like to do notification in Rust
-        rustrt::rust_task_config_notify(task_id, c);
+        rustrt::rust_task_config_notify(new_task, c);
     }
 
-    rustrt::start_task(task_id, closure);
+    rustrt::start_task(new_task, closure);
     unsafe::leak(f);
 
-    fn new_task_in_new_sched(opts: sched_opts) -> task_id {
+    fn new_task_in_new_sched(opts: sched_opts) -> *rust_task {
         if opts.native_stack_size != none {
             fail "native_stack_size scheduler option unimplemented";
         }
@@ -543,13 +543,13 @@ native mod rustrt {
     fn get_task_id() -> task_id;
     fn rust_get_task() -> *rust_task;
 
-    fn new_task() -> task_id;
-    fn rust_new_task_in_sched(id: sched_id) -> task_id;
+    fn new_task() -> *rust_task;
+    fn rust_new_task_in_sched(id: sched_id) -> *rust_task;
 
     fn rust_task_config_notify(
-        id: task_id, &&chan: comm::chan<notification>);
+        task: *rust_task, &&chan: comm::chan<notification>);
 
-    fn start_task(id: task_id, closure: *rust_closure);
+    fn start_task(task: *rust_task, closure: *rust_closure);
 
     fn rust_task_is_unwinding(rt: *rust_task) -> bool;
     fn unsupervise();
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 121f3d4bcfc..3f5f083650f 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -81,9 +81,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
     rust_kernel *kernel = new rust_kernel(srv);
     rust_sched_id sched_id = kernel->create_scheduler(env->num_sched_threads);
     rust_scheduler *sched = kernel->get_scheduler_by_id(sched_id);
-    rust_task_id root_id = sched->create_task(NULL, "main", MAIN_STACK_SIZE);
-    rust_task *root_task = kernel->get_task_by_id(root_id);
-    I(kernel, root_task != NULL);
+    rust_task *root_task = sched->create_task(NULL, "main", MAIN_STACK_SIZE);
     rust_task_thread *thread = root_task->thread;
     command_line_args *args
         = new (kernel, "main command line args")
@@ -96,7 +94,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
     }
 
     root_task->start((spawn_fn)main_fn, NULL, args->args);
-    root_task->deref();
     root_task = NULL;
 
     int ret = kernel->wait_for_schedulers();
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index de782c355c3..aa5b60f87a9 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -424,18 +424,18 @@ get_task_id() {
     return task->id;
 }
 
-static rust_task_id
+static rust_task*
 new_task_common(rust_scheduler *sched, rust_task *parent) {
     return sched->create_task(parent, NULL);
 }
 
-extern "C" CDECL rust_task_id
+extern "C" CDECL rust_task*
 new_task() {
     rust_task *task = rust_task_thread::get_task();
     return new_task_common(task->sched, task);
 }
 
-extern "C" CDECL rust_task_id
+extern "C" CDECL rust_task*
 rust_new_task_in_sched(rust_sched_id id) {
     rust_task *task = rust_task_thread::get_task();
     rust_scheduler *sched = task->kernel->get_scheduler_by_id(id);
@@ -444,13 +444,8 @@ rust_new_task_in_sched(rust_sched_id id) {
 }
 
 extern "C" CDECL void
-rust_task_config_notify(rust_task_id task_id, chan_handle *chan) {
-    rust_task *task = rust_task_thread::get_task();
-    rust_task *target = task->kernel->get_task_by_id(task_id);
-    A(task->thread, target != NULL,
-      "This function should only be called when we know the task exists");
+rust_task_config_notify(rust_task *target, chan_handle *chan) {
     target->config_notify(*chan);
-    target->deref();
 }
 
 extern "C" rust_task *
@@ -459,11 +454,8 @@ rust_get_task() {
 }
 
 extern "C" CDECL void
-start_task(rust_task_id id, fn_env_pair *f) {
-    rust_task *task = rust_task_thread::get_task();
-    rust_task *target = task->kernel->get_task_by_id(id);
+start_task(rust_task *target, fn_env_pair *f) {
     target->start(f->f, f->env, NULL);
-    target->deref();
 }
 
 extern "C" CDECL int
diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp
index c2906bc51a0..0fc3e78d85e 100644
--- a/src/rt/rust_scheduler.cpp
+++ b/src/rt/rust_scheduler.cpp
@@ -82,7 +82,7 @@ rust_scheduler::kill_all_tasks() {
     }
 }
 
-rust_task_id
+rust_task *
 rust_scheduler::create_task(rust_task *spawner, const char *name,
 			    size_t init_stack_sz) {
     size_t thread_no;
@@ -95,7 +95,7 @@ rust_scheduler::create_task(rust_task *spawner, const char *name,
     return thread->create_task(spawner, name, init_stack_sz);
 }
 
-rust_task_id
+rust_task *
 rust_scheduler::create_task(rust_task *spawner, const char *name) {
     return create_task(spawner, name, env->min_stack_size);
 }
diff --git a/src/rt/rust_scheduler.h b/src/rt/rust_scheduler.h
index 936e2e992c4..f12e053e4cf 100644
--- a/src/rt/rust_scheduler.h
+++ b/src/rt/rust_scheduler.h
@@ -39,10 +39,10 @@ public:
     void start_task_threads();
     void join_task_threads();
     void kill_all_tasks();
-    rust_task_id create_task(rust_task *spawner,
-			     const char *name,
-			     size_t init_stack_sz);
-    rust_task_id create_task(rust_task *spawner, const char *name);
+    rust_task* create_task(rust_task *spawner,
+			   const char *name,
+			   size_t init_stack_sz);
+    rust_task* create_task(rust_task *spawner, const char *name);
 
     void release_task();
 
diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp
index e108a21f3a9..a167c63cfe2 100644
--- a/src/rt/rust_task_thread.cpp
+++ b/src/rt/rust_task_thread.cpp
@@ -159,8 +159,6 @@ void
 rust_task_thread::release_task(rust_task *task) {
     // Nobody should have a ref to the task at this point
     I(this, task->get_ref_count() == 0);
-    // Kernel should not know about the task any more
-    I(this, kernel->get_task_by_id(task->id) == NULL);
     // Now delete the task, which will require using this thread's
     // memory region.
     delete task;
@@ -304,7 +302,7 @@ rust_task_thread::get_cache() {
     return &cache;
 }
 
-rust_task_id
+rust_task *
 rust_task_thread::create_task(rust_task *spawner, const char *name,
                             size_t init_stack_sz) {
     rust_task *task =
@@ -319,7 +317,7 @@ rust_task_thread::create_task(rust_task *spawner, const char *name,
     }
 
     kernel->register_task(task);
-    return task->id;
+    return task;
 }
 
 void 
diff --git a/src/rt/rust_task_thread.h b/src/rt/rust_task_thread.h
index f29e165d942..662b767a552 100644
--- a/src/rt/rust_task_thread.h
+++ b/src/rt/rust_task_thread.h
@@ -120,8 +120,8 @@ public:
 
     void kill_all_tasks();
 
-    rust_task_id create_task(rust_task *spawner, const char *name,
-                             size_t init_stack_sz);
+    rust_task *create_task(rust_task *spawner, const char *name,
+                           size_t init_stack_sz);
 
     void transition(rust_task *task,
                     rust_task_list *src, rust_task_list *dst,