From a493350eb5ab38ba8a6563f3eb4a090d257b0d3a Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Fri, 10 Sep 2010 01:21:29 -0700 Subject: Cleanup, refactoring, and some runtime tests. --- src/rt/util/indexed_list.h | 16 +++++++++++++--- src/rt/util/synchronized_indexed_list.h | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/rt/util') diff --git a/src/rt/util/indexed_list.h b/src/rt/util/indexed_list.h index d643a050..df887122 100644 --- a/src/rt/util/indexed_list.h +++ b/src/rt/util/indexed_list.h @@ -3,7 +3,6 @@ #include #include "array_list.h" -#include "../memory_region.h" class indexed_list_object { public: @@ -28,12 +27,14 @@ public: * object inserted in this list must define a "int32_t list_index" member. */ template class indexed_list { - memory_region *region; array_list list; public: - indexed_list(memory_region *region) : region(region) {} virtual int32_t append(T *value); virtual bool pop(T **value); + /** + * Same as pop(), except that it returns NULL if the list is empty. + */ + virtual T* pop_value(); virtual size_t length() { return list.size(); } @@ -76,6 +77,15 @@ indexed_list::pop(T **value) { return list.pop(value); } +template T* +indexed_list::pop_value() { + T *value = NULL; + if (list.pop(&value)) { + return value; + } + return NULL; +} + template T * indexed_list::operator[](int32_t index) { T *value = list[index]; diff --git a/src/rt/util/synchronized_indexed_list.h b/src/rt/util/synchronized_indexed_list.h index 6b561171..52fabe05 100644 --- a/src/rt/util/synchronized_indexed_list.h +++ b/src/rt/util/synchronized_indexed_list.h @@ -2,14 +2,14 @@ #define SYNCHRONIZED_INDEXED_LIST_H #include "indexed_list.h" +#include "../sync/lock_and_signal.h" template class synchronized_indexed_list : public indexed_list { lock_and_signal _lock; public: - synchronized_indexed_list(memory_region *region) : - indexed_list(region) { + synchronized_indexed_list() { // Nop. } -- cgit v1.2.3