Change signature of array_list::pop().

This commit is contained in:
Michael Bebenita
2010-09-07 18:18:37 -07:00
parent 6b7ba50e17
commit b03812af2b
3 changed files with 22 additions and 7 deletions

View File

@@ -400,7 +400,8 @@ rust_task::notify_tasks_waiting_to_join() {
while (tasks_waiting_to_join.is_empty() == false) { while (tasks_waiting_to_join.is_empty() == false) {
log(rust_log::TASK, "notify_tasks_waiting_to_join: %d", log(rust_log::TASK, "notify_tasks_waiting_to_join: %d",
tasks_waiting_to_join.size()); 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()) { if (waiting_task->is_proxy()) {
notify_message::send(notify_message::WAKEUP, "wakeup", notify_message::send(notify_message::WAKEUP, "wakeup",
this, waiting_task->as_proxy()); this, waiting_task->as_proxy());

View File

@@ -15,7 +15,7 @@ public:
size_t size(); size_t size();
int32_t append(T value); int32_t append(T value);
int32_t push(T value); int32_t push(T value);
T pop(); bool pop(T *value);
bool replace(T old_value, T new_value); bool replace(T old_value, T new_value);
int32_t index_of(T value); int32_t index_of(T value);
bool is_empty(); bool is_empty();
@@ -54,10 +54,17 @@ array_list<T>::push(T value) {
return _size - 1; return _size - 1;
} }
template<typename T> T template<typename T> bool
array_list<T>::pop() { array_list<T>::pop(T *value) {
T value = _data[-- _size]; if (_size == 0) {
return value; return false;
}
if (value != NULL) {
*value = _data[-- _size];
} else {
-- _size;
}
return true;
} }
/** /**

View File

@@ -24,6 +24,7 @@ template<typename T> class indexed_list {
public: public:
indexed_list(memory_region &region) : region(region) {} indexed_list(memory_region &region) : region(region) {}
virtual int32_t append(T *value); virtual int32_t append(T *value);
virtual bool pop(T **value);
virtual size_t length() { virtual size_t length() {
return list.size(); return list.size();
} }
@@ -48,7 +49,8 @@ indexed_list<T>::remove(T *value) {
assert (value->list_index >= 0); assert (value->list_index >= 0);
assert (value->list_index < (int32_t)list.size()); assert (value->list_index < (int32_t)list.size());
int32_t removeIndex = value->list_index; int32_t removeIndex = value->list_index;
T *last = list.pop(); T *last;
list.pop(&last);
if (last->list_index == removeIndex) { if (last->list_index == removeIndex) {
last->list_index = -1; last->list_index = -1;
return removeIndex; 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 * template <typename T> T *
indexed_list<T>::operator[](int32_t index) { indexed_list<T>::operator[](int32_t index) {
T *value = list[index]; T *value = list[index];