diff options
| author | Michael Bebenita <[email protected]> | 2010-09-10 01:21:29 -0700 |
|---|---|---|
| committer | Michael Bebenita <[email protected]> | 2010-09-10 14:38:31 -0700 |
| commit | a493350eb5ab38ba8a6563f3eb4a090d257b0d3a (patch) | |
| tree | dc984eaa28a55de9f05db0b961a0e67f80ca35ef /src/rt/util | |
| parent | Added lock_and_signal::signal_all(), and made the rust_kernel::join() use wai... (diff) | |
| download | rust-a493350eb5ab38ba8a6563f3eb4a090d257b0d3a.tar.xz rust-a493350eb5ab38ba8a6563f3eb4a090d257b0d3a.zip | |
Cleanup, refactoring, and some runtime tests.
Diffstat (limited to 'src/rt/util')
| -rw-r--r-- | src/rt/util/indexed_list.h | 16 | ||||
| -rw-r--r-- | src/rt/util/synchronized_indexed_list.h | 4 |
2 files changed, 15 insertions, 5 deletions
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 <assert.h> #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<typename T> class indexed_list { - memory_region *region; array_list<T*> 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<T>::pop(T **value) { return list.pop(value); } +template<typename T> T* +indexed_list<T>::pop_value() { + T *value = NULL; + if (list.pop(&value)) { + return value; + } + return NULL; +} + template <typename T> T * indexed_list<T>::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<typename T> class synchronized_indexed_list : public indexed_list<T> { lock_and_signal _lock; public: - synchronized_indexed_list(memory_region *region) : - indexed_list<T>(region) { + synchronized_indexed_list() { // Nop. } |