From 0667fb4e6342a6a18320b464316ae7ba9c2bc192 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 8 Feb 2012 20:52:52 -0800 Subject: [PATCH] rt: Make rust_task::ref_count private --- src/rt/rust_internal.h | 3 ++- src/rt/rust_kernel.cpp | 1 + src/rt/rust_task_thread.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index b6bd20fc98bd..4fc6a4cfb1ec 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -105,8 +105,9 @@ static size_t const BUF_BYTES = 2048; void deref() { if (--ref_count == 0) { dtor; } } #define RUST_ATOMIC_REFCOUNT() \ -public: \ +private: \ intptr_t ref_count; \ +public: \ void ref() { \ intptr_t old = sync::increment(ref_count); \ assert(old > 0); \ diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 9768fffaf0b0..8752ea37be99 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -190,6 +190,7 @@ rust_kernel::get_task_by_id(rust_task_id id) { task_table.get(id, &task); if(task) { if(task->get_ref_count() == 0) { + // FIXME: I don't think this is possible. // this means the destructor is running, since the destructor // grabs the kernel lock to unregister the task. Pretend this // doesn't actually exist. diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp index 4830e1254d5b..41242fee9d3f 100644 --- a/src/rt/rust_task_thread.cpp +++ b/src/rt/rust_task_thread.cpp @@ -149,7 +149,7 @@ rust_task_thread::reap_dead_tasks() { void rust_task_thread::release_task(rust_task *task) { // Nobody should have a ref to the task at this point - I(this, task->ref_count == 0); + I(this, task->get_ref_count() == 0); // Kernel should not know about the task any more I(this, kernel->get_task_by_id(task->id) == NULL); // Now delete the task, which will require using this thread's