about summary refs log tree commit diff
path: root/src/rt/rust_chan.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-19 14:31:55 -0700
committerBrian Anderson <banderson@mozilla.com>2011-07-21 11:51:22 -0700
commitd79afd7916dc2b5353666c301b93c09fdba29134 (patch)
tree90c8c310a21a8126be1cd1eecaedcf3ddfd636e1 /src/rt/rust_chan.cpp
parent3ae4dcd41e72d197e3882835253745f79588b04a (diff)
downloadrust-d79afd7916dc2b5353666c301b93c09fdba29134.tar.gz
rust-d79afd7916dc2b5353666c301b93c09fdba29134.zip
Improving move semantics for channel operations.
This lets us un-XFAIL task-comm-10.rs.
Diffstat (limited to 'src/rt/rust_chan.cpp')
-rw-r--r--src/rt/rust_chan.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp
index 23af8a5fef6..92edaa77650 100644
--- a/src/rt/rust_chan.cpp
+++ b/src/rt/rust_chan.cpp
@@ -4,12 +4,10 @@
 /**
  * Create a new rust channel and associate it with the specified port.
  */
-rust_chan::rust_chan(rust_task *task,
-                     maybe_proxy<rust_port> *port,
+rust_chan::rust_chan(rust_kernel *kernel, maybe_proxy<rust_port> *port,
                      size_t unit_sz)
     : ref_count(1),
-      kernel(task->kernel),
-      task(task),
+      kernel(kernel),
       port(port),
       buffer(kernel, unit_sz) {
     if (port) {
@@ -39,6 +37,7 @@ void rust_chan::associate(maybe_proxy<rust_port> *port) {
             this, port);
         ++this->ref_count;
         this->task = port->referent()->task;
+        this->task->ref();
         this->port->referent()->chans.push(this);
     }
 }
@@ -59,6 +58,7 @@ void rust_chan::disassociate() {
             "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
             this, port->referent());
         --this->ref_count;
+        --this->task->ref_count;
         this->task = NULL;
         port->referent()->chans.swap_delete(this);
     }
@@ -118,7 +118,7 @@ rust_chan *rust_chan::clone(maybe_proxy<rust_task> *target) {
         target_task = target->as_proxy()->handle()->referent();
     }
     return new (target_task->kernel, "cloned chan")
-        rust_chan(target_task, port, unit_sz);
+        rust_chan(kernel, port, unit_sz);
 }
 
 /**