about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorRob Arnold <robarnold@cs.cmu.edu>2011-06-30 19:27:35 -0700
committerEric Holk <eholk@mozilla.com>2011-07-01 16:59:11 -0700
commit4e59b0be544bfda5c533c2024c981861ce012709 (patch)
tree2f9941d1e49bb5a26808f26b61d172f29cf3a03b /src/rt
parent02a5949abaa4e888ecb470023ea2f29cd6bde43b (diff)
downloadrust-4e59b0be544bfda5c533c2024c981861ce012709.tar.gz
rust-4e59b0be544bfda5c533c2024c981861ce012709.zip
Sync rust_chan's deref() method with rustc's code.
If the channel is associated with a port then the destructor will assert.
Additionally, destruction of the object is not always appropriate. This brings
the deref() method into sync with the behavior of generated rust code which
only invokes destroy() once the reference count goes to 0.
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_chan.cpp1
-rw-r--r--src/rt/rust_chan.h4
2 files changed, 3 insertions, 2 deletions
diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp
index 3065a55e582..78301e3d879 100644
--- a/src/rt/rust_chan.cpp
+++ b/src/rt/rust_chan.cpp
@@ -7,6 +7,7 @@
 rust_chan::rust_chan(rust_task *task,
                      maybe_proxy<rust_port> *port,
                      size_t unit_sz) :
+                     ref_count(1),
                      task(task),
                      port(port),
                      buffer(task, unit_sz) {
diff --git a/src/rt/rust_chan.h b/src/rt/rust_chan.h
index a327dbf0c95..4172ca5f09d 100644
--- a/src/rt/rust_chan.h
+++ b/src/rt/rust_chan.h
@@ -1,10 +1,10 @@
 #ifndef RUST_CHAN_H
 #define RUST_CHAN_H
 
-class rust_chan : public rc_base<rust_chan>,
-                  public task_owned<rust_chan>,
+class rust_chan : public task_owned<rust_chan>,
                   public rust_cond {
 public:
+    RUST_REFCOUNTED_WITH_DTOR(rust_chan, destroy())
     rust_chan(rust_task *task, maybe_proxy<rust_port> *port, size_t unit_sz);
 
     ~rust_chan();