about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-03-14 17:24:19 -0700
committerBrian Anderson <banderson@mozilla.com>2012-03-15 11:10:52 -0700
commitb278d675a231fdfe825c72e499d59e8a3d07ffaa (patch)
tree426a39a89561d56ac72e328aecc64c045a578e18 /src/rt/rust_task.cpp
parent337d860a8777a761267daaad9b561787b10e7c87 (diff)
downloadrust-b278d675a231fdfe825c72e499d59e8a3d07ffaa.tar.gz
rust-b278d675a231fdfe825c72e499d59e8a3d07ffaa.zip
rt: Look up ports through a single port table
Instead of a two-level lookup, just use one big table
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp54
1 files changed, 9 insertions, 45 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index bb56b4dcb0a..aba93576700 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -75,7 +75,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
     kernel(thread->kernel),
     name(name),
     list_index(-1),
-    next_port_id(0),
     rendezvous_ptr(0),
     local_region(&thread->srv->local_region),
     boxed(&local_region),
@@ -107,11 +106,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
 void
 rust_task::delete_this()
 {
-    {
-        scoped_lock with (port_lock);
-        I(thread, port_table.is_empty());
-    }
-
     DLOG(thread, task, "~rust_task %s @0x%" PRIxPTR ", refcnt=%d",
          name, (uintptr_t)this, ref_count);
 
@@ -476,49 +470,19 @@ rust_task::calloc(size_t size, const char *tag) {
     return local_region.calloc(size, tag);
 }
 
-rust_port_id rust_task::register_port(rust_port *port) {
-    I(thread, !port_lock.lock_held_by_current_thread());
-    scoped_lock with(port_lock);
-
-    rust_port_id id = next_port_id++;
-    A(thread, id != INTPTR_MAX, "Hit the maximum port id");
-    port_table.put(id, port);
-    return id;
-}
-
-void rust_task::release_port(rust_port_id id) {
-    scoped_lock with(port_lock);
-    port_table.remove(id);
-}
-
-rust_port *rust_task::get_port_by_id(rust_port_id id) {
-    I(thread, !port_lock.lock_held_by_current_thread());
-    scoped_lock with(port_lock);
-    rust_port *port = NULL;
-    port_table.get(id, &port);
-    if (port) {
-        port->ref();
-    }
-    return port;
-}
-
 void
 rust_task::notify(bool success) {
     // FIXME (1078) Do this in rust code
     if(notify_enabled) {
-        rust_task *target_task = kernel->get_task_by_id(notify_chan.task);
-        if (target_task) {
-            rust_port *target_port =
-                target_task->get_port_by_id(notify_chan.port);
-            if(target_port) {
-                task_notification msg;
-                msg.id = id;
-                msg.result = !success ? tr_failure : tr_success;
-
-                target_port->send(&msg);
-                target_port->deref();
-            }
-            target_task->deref();
+        rust_port *target_port =
+            kernel->get_port_by_id(notify_chan.port);
+        if(target_port) {
+            task_notification msg;
+            msg.id = id;
+            msg.result = !success ? tr_failure : tr_success;
+
+            target_port->send(&msg);
+            target_port->deref();
         }
     }
 }