Skip to content

Commit 4e59b0b

Browse files
robarnoldEric Holk
authored and
Eric Holk
committed
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.
1 parent 02a5949 commit 4e59b0b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/rt/rust_chan.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
rust_chan::rust_chan(rust_task *task,
88
maybe_proxy<rust_port> *port,
99
size_t unit_sz) :
10+
ref_count(1),
1011
task(task),
1112
port(port),
1213
buffer(task, unit_sz) {

src/rt/rust_chan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef RUST_CHAN_H
22
#define RUST_CHAN_H
33

4-
class rust_chan : public rc_base<rust_chan>,
5-
public task_owned<rust_chan>,
4+
class rust_chan : public task_owned<rust_chan>,
65
public rust_cond {
76
public:
7+
RUST_REFCOUNTED_WITH_DTOR(rust_chan, destroy())
88
rust_chan(rust_task *task, maybe_proxy<rust_port> *port, size_t unit_sz);
99

1010
~rust_chan();

0 commit comments

Comments
 (0)