diff options
| author | Michael Bebenita <[email protected]> | 2010-09-07 18:18:37 -0700 |
|---|---|---|
| committer | Michael Bebenita <[email protected]> | 2010-09-07 18:41:08 -0700 |
| commit | b03812af2b65a31c567945a1c41515602ff92c20 (patch) | |
| tree | 356d9feffe19d4ad91d4525f2d6b6083269db442 /src/rt | |
| parent | Added "new" inline operators to memory regions. (diff) | |
| download | rust-b03812af2b65a31c567945a1c41515602ff92c20.tar.xz rust-b03812af2b65a31c567945a1c41515602ff92c20.zip | |
Change signature of array_list::pop().
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_task.cpp | 3 | ||||
| -rw-r--r-- | src/rt/util/array_list.h | 17 | ||||
| -rw-r--r-- | src/rt/util/indexed_list.h | 9 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 9497645b..08d5974e 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -400,7 +400,8 @@ rust_task::notify_tasks_waiting_to_join() { while (tasks_waiting_to_join.is_empty() == false) { log(rust_log::TASK, "notify_tasks_waiting_to_join: %d", tasks_waiting_to_join.size()); - maybe_proxy<rust_task> *waiting_task = tasks_waiting_to_join.pop(); + maybe_proxy<rust_task> *waiting_task; + tasks_waiting_to_join.pop(&waiting_task); if (waiting_task->is_proxy()) { notify_message::send(notify_message::WAKEUP, "wakeup", this, waiting_task->as_proxy()); diff --git a/src/rt/util/array_list.h b/src/rt/util/array_list.h index 929117f3..d44111e8 100644 --- a/src/rt/util/array_list.h +++ b/src/rt/util/array_list.h @@ -15,7 +15,7 @@ public: size_t size(); int32_t append(T value); int32_t push(T value); - T pop(); + bool pop(T *value); bool replace(T old_value, T new_value); int32_t index_of(T value); bool is_empty(); @@ -54,10 +54,17 @@ array_list<T>::push(T value) { return _size - 1; } -template<typename T> T -array_list<T>::pop() { - T value = _data[-- _size]; - return value; +template<typename T> bool +array_list<T>::pop(T *value) { + if (_size == 0) { + return false; + } + if (value != NULL) { + *value = _data[-- _size]; + } else { + -- _size; + } + return true; } /** diff --git a/src/rt/util/indexed_list.h b/src/rt/util/indexed_list.h index d869d43e..cd39a0b6 100644 --- a/src/rt/util/indexed_list.h +++ b/src/rt/util/indexed_list.h @@ -24,6 +24,7 @@ template<typename T> class indexed_list { public: indexed_list(memory_region ®ion) : region(region) {} virtual int32_t append(T *value); + virtual bool pop(T **value); virtual size_t length() { return list.size(); } @@ -48,7 +49,8 @@ indexed_list<T>::remove(T *value) { assert (value->list_index >= 0); assert (value->list_index < (int32_t)list.size()); int32_t removeIndex = value->list_index; - T *last = list.pop(); + T *last; + list.pop(&last); if (last->list_index == removeIndex) { last->list_index = -1; return removeIndex; @@ -60,6 +62,11 @@ indexed_list<T>::remove(T *value) { } } +template<typename T> bool +indexed_list<T>::pop(T **value) { + return list.pop(value); +} + template <typename T> T * indexed_list<T>::operator[](int32_t index) { T *value = list[index]; |