Skip to content

Commit eb368d1

Browse files
committed
Remove rc_base. Closes #603.
1 parent 28fbc59 commit eb368d1

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

src/rt/rust_internal.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ static intptr_t const CONST_REFCOUNT = 0x7badface;
106106

107107
static size_t const BUF_BYTES = 2048;
108108

109-
// Every reference counted object should derive from this base class.
110-
// Or use this macro. The macro is preferred as the base class will be
111-
// disappearing.
109+
// Every reference counted object should use this macro and initialize
110+
// ref_count.
112111

113112
#define RUST_REFCOUNTED(T) \
114113
RUST_REFCOUNTED_WITH_DTOR(T, delete (T*)this)
@@ -127,13 +126,6 @@ public: \
127126
} \
128127
void deref() { if(0 == sync::decrement(ref_count)) { delete this; } }
129128

130-
template <typename T> struct rc_base {
131-
RUST_REFCOUNTED(T)
132-
133-
rc_base();
134-
~rc_base();
135-
};
136-
137129
template <typename T> struct task_owned {
138130
inline void *operator new(size_t size, rust_task *task, const char *tag);
139131

src/rt/rust_scheduler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
rust_scheduler::rust_scheduler(rust_kernel *kernel,
77
rust_srv *srv,
88
int id) :
9+
ref_count(1),
910
interrupt_flag(0),
1011
_log(srv, this),
1112
log_lvl(log_note),

src/rt/rust_scheduler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ rust_crate_cache
2727
};
2828

2929
struct rust_scheduler : public kernel_owned<rust_scheduler>,
30-
rc_base<rust_scheduler>,
3130
rust_thread
3231
{
32+
RUST_REFCOUNTED(rust_scheduler)
33+
3334
// Fields known to the compiler:
3435
uintptr_t interrupt_flag;
3536

src/rt/rust_util.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44
#include "rust_task.h"
55
#include <limits.h>
66

7-
// Reference counted objects
8-
9-
template <typename T>
10-
rc_base<T>::rc_base() :
11-
ref_count(1)
12-
{
13-
}
14-
15-
template <typename T>
16-
rc_base<T>::~rc_base()
17-
{
18-
}
19-
207
// Utility type: pointer-vector.
218

229
template <typename T>
@@ -181,15 +168,18 @@ isaac_init(sched_or_kernel *sched, randctx *rctx)
181168
// Vectors (rust-user-code level).
182169

183170
struct
184-
rust_evec : public rc_base<rust_evec>
171+
rust_evec
185172
{
173+
RUST_REFCOUNTED(rust_evec)
174+
186175
size_t alloc;
187176
size_t fill;
188177
size_t pad; // Pad to align data[0] to 16 bytes.
189178
uint8_t data[];
190179
rust_evec(size_t alloc, size_t fill,
191180
uint8_t const *d)
192-
: alloc(alloc),
181+
: ref_count(1),
182+
alloc(alloc),
193183
fill(fill)
194184
{
195185
if (d)

0 commit comments

Comments
 (0)