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.
This commit is contained in:
Rob Arnold 2011-06-30 19:27:35 -07:00 committed by Eric Holk
parent 02a5949aba
commit 4e59b0be54
2 changed files with 3 additions and 2 deletions

View File

@ -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) {

View File

@ -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();