From eb368d1b346a0cd6a9db3fc33ce3b563f68a5d84 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Thu, 18 Aug 2011 15:49:58 -0700 Subject: [PATCH] Remove rc_base. Closes #603. --- src/rt/rust_internal.h | 12 ++---------- src/rt/rust_scheduler.cpp | 1 + src/rt/rust_scheduler.h | 3 ++- src/rt/rust_util.h | 20 +++++--------------- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index aa9f387a9f9a..486e985f6147 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -106,9 +106,8 @@ static intptr_t const CONST_REFCOUNT = 0x7badface; static size_t const BUF_BYTES = 2048; -// Every reference counted object should derive from this base class. -// Or use this macro. The macro is preferred as the base class will be -// disappearing. +// Every reference counted object should use this macro and initialize +// ref_count. #define RUST_REFCOUNTED(T) \ RUST_REFCOUNTED_WITH_DTOR(T, delete (T*)this) @@ -127,13 +126,6 @@ public: \ } \ void deref() { if(0 == sync::decrement(ref_count)) { delete this; } } -template struct rc_base { - RUST_REFCOUNTED(T) - - rc_base(); - ~rc_base(); -}; - template struct task_owned { inline void *operator new(size_t size, rust_task *task, const char *tag); diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 913f489c382c..5595ca51a55c 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -6,6 +6,7 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel, rust_srv *srv, int id) : + ref_count(1), interrupt_flag(0), _log(srv, this), log_lvl(log_note), diff --git a/src/rt/rust_scheduler.h b/src/rt/rust_scheduler.h index b4a70e51f686..6969034f725e 100644 --- a/src/rt/rust_scheduler.h +++ b/src/rt/rust_scheduler.h @@ -27,9 +27,10 @@ public: }; struct rust_scheduler : public kernel_owned, - rc_base, rust_thread { + RUST_REFCOUNTED(rust_scheduler) + // Fields known to the compiler: uintptr_t interrupt_flag; diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index 64b7d35623cd..aab3e15e4641 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -4,19 +4,6 @@ #include "rust_task.h" #include -// Reference counted objects - -template -rc_base::rc_base() : - ref_count(1) -{ -} - -template -rc_base::~rc_base() -{ -} - // Utility type: pointer-vector. template @@ -181,15 +168,18 @@ isaac_init(sched_or_kernel *sched, randctx *rctx) // Vectors (rust-user-code level). struct -rust_evec : public rc_base +rust_evec { + RUST_REFCOUNTED(rust_evec) + size_t alloc; size_t fill; size_t pad; // Pad to align data[0] to 16 bytes. uint8_t data[]; rust_evec(size_t alloc, size_t fill, uint8_t const *d) - : alloc(alloc), + : ref_count(1), + alloc(alloc), fill(fill) { if (d)