aboutsummaryrefslogtreecommitdiff
path: root/src/rt/util/indexed_list.h
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-09-10 01:21:29 -0700
committerMichael Bebenita <[email protected]>2010-09-10 14:38:31 -0700
commita493350eb5ab38ba8a6563f3eb4a090d257b0d3a (patch)
treedc984eaa28a55de9f05db0b961a0e67f80ca35ef /src/rt/util/indexed_list.h
parentAdded lock_and_signal::signal_all(), and made the rust_kernel::join() use wai... (diff)
downloadrust-a493350eb5ab38ba8a6563f3eb4a090d257b0d3a.tar.xz
rust-a493350eb5ab38ba8a6563f3eb4a090d257b0d3a.zip
Cleanup, refactoring, and some runtime tests.
Diffstat (limited to 'src/rt/util/indexed_list.h')
-rw-r--r--src/rt/util/indexed_list.h16
1 files changed, 13 insertions, 3 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];