From 4e59b0be544bfda5c533c2024c981861ce012709 Mon Sep 17 00:00:00 2001 From: Rob Arnold Date: Thu, 30 Jun 2011 19:27:35 -0700 Subject: [PATCH] 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. --- src/rt/rust_chan.cpp | 1 + src/rt/rust_chan.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp index 3065a55e58260..78301e3d879dd 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 *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 a327dbf0c95d4..4172ca5f09d86 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, - public task_owned, +class rust_chan : public task_owned, public rust_cond { public: + RUST_REFCOUNTED_WITH_DTOR(rust_chan, destroy()) rust_chan(rust_task *task, maybe_proxy *port, size_t unit_sz); ~rust_chan();