about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-11 11:46:07 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-11 12:11:21 -0800
commit5d1e321ecbdaf50fe4723b698081c7cda60d366a (patch)
treeb9d5bc27f8787a81a67647db4543ed3204040721 /src/rt/rust_builtin.cpp
parent39084fb881a1a0fd2db6c8df04ccd5cc0a9c6716 (diff)
downloadrust-5d1e321ecbdaf50fe4723b698081c7cda60d366a.tar.gz
rust-5d1e321ecbdaf50fe4723b698081c7cda60d366a.zip
rt: Remove rust_chan
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 4086e3708fd..3b69fcf9466 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -463,8 +463,7 @@ new_port(size_t unit_sz) {
     rust_task *task = rust_scheduler::get_task();
     LOG(task, comm, "new_port(task=0x%" PRIxPTR " (%s), unit_sz=%d)",
         (uintptr_t) task, task->name, unit_sz);
-    // take a reference on behalf of the port
-    task->ref();
+    // port starts with refcount == 1
     return new (task->kernel, "rust_port") rust_port(task, unit_sz);
 }
 
@@ -472,11 +471,7 @@ extern "C" CDECL void
 del_port(rust_port *port) {
     rust_task *task = rust_scheduler::get_task();
     LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port);
-    I(task->sched, !port->ref_count);
-    delete port;
-
-    // FIXME: this should happen in the port.
-    task->deref();
+    port->deref();
 }
 
 extern "C" CDECL rust_port_id
@@ -486,7 +481,6 @@ get_port_id(rust_port *port) {
 
 extern "C" CDECL
 void drop_port(rust_port *port) {
-    port->ref_count--;
 }
 
 extern "C" CDECL void
@@ -497,10 +491,11 @@ chan_id_send(type_desc *t, rust_task_id target_task_id,
     rust_task *target_task = task->kernel->get_task_by_id(target_task_id);
     if(target_task) {
         rust_port *port = target_task->get_port_by_id(target_port_id);
+        target_task->deref();
         if(port) {
             port->send(sptr);
+            port->deref();
         }
-        target_task->deref();
     }
 }