case ATOMIC_NOTIFY_ALL: {
action_list_t *waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location());
//activate all the waiting threads
- for (action_list_t::iterator rit = waiters->begin();rit != waiters->end();rit++) {
- scheduler->wake(get_thread(*rit));
+ for (sllnode<ModelAction *> * rit = waiters->begin();rit != NULL;rit=rit->getNext()) {
+ scheduler->wake(get_thread(rit->getVal()));
}
waiters->clear();
break;
#include <list>
#include "mymemory.h"
+typedef unsigned int uint;
+
template<typename _Tp>
class mllnode {
{
public:
ModelList() : head(NULL),
- tail(NULL) {
+ tail(NULL), _size(0) {
}
void push_front(_Tp val) {
else
head->prev = tmp;
head = tmp;
+ _size++;
}
void push_back(_Tp val) {
head = tmp;
else tail->next = tmp;
tail = tmp;
+ _size++;
+ }
+
+ void pop_front() {
+ mllnode<_Tp> *tmp = head;
+ head = head->next;
+ head->prev = NULL;
+ delete tmp;
+ _size--;
+ }
+
+ void pop_back() {
+ mllnode<_Tp> *tmp = tail;
+ tail = tail->next;
+ tail->next = NULL;
+ delete tmp;
+ _size--;
}
+ void clear() {
+ while(head != NULL) {
+ mllnode<_Tp> *tmp=head->next;
+ delete head;
+ head = tmp;
+ }
+ tail=NULL;
+ _size=0;
+ }
+
void insertAfter(mllnode<_Tp> * node, _Tp val) {
mllnode<_Tp> *tmp = new mllnode<_Tp>();
tmp->val = val;
} else {
tmp->next->prev = tmp;
}
+ _size++;
}
void insertBefore(mllnode<_Tp> * node, _Tp val) {
} else {
tmp->prev->next = tmp;
}
+ _size++;
}
mllnode<_Tp> * erase(mllnode<_Tp> * node) {
}
mllnode<_Tp> *next = node->next;
delete node;
+ _size--;
return next;
}
_Tp back() {
return tail->val;
}
-
+
+ uint size() {
+ return _size;
+ }
MEMALLOC;
private:
mllnode<_Tp> *head;
mllnode<_Tp> *tail;
+ uint _size;
};
template<typename _Tp>
{
public:
SnapList() : head(NULL),
- tail(NULL) {
+ tail(NULL), _size(0) {
}
void push_front(_Tp val) {
else
head->prev = tmp;
head = tmp;
+ _size++;
}
void push_back(_Tp val) {
head = tmp;
else tail->next = tmp;
tail = tmp;
+ _size++;
+ }
+
+ void pop_front() {
+ sllnode<_Tp> *tmp = head;
+ head = head->next;
+ head->prev = NULL;
+ delete tmp;
+ _size--;
}
+ void pop_back() {
+ sllnode<_Tp> *tmp = tail;
+ tail = tail->next;
+ tail->next = NULL;
+ delete tmp;
+ _size--;
+ }
+
+ void clear() {
+ while(head != NULL) {
+ sllnode<_Tp> *tmp=head->next;
+ delete head;
+ head = tmp;
+ }
+ tail=NULL;
+ _size=0;
+ }
+
void insertAfter(sllnode<_Tp> * node, _Tp val) {
sllnode<_Tp> *tmp = new sllnode<_Tp>();
tmp->val = val;
} else {
tmp->next->prev = tmp;
}
+ _size++;
}
void insertBefore(sllnode<_Tp> * node, _Tp val) {
} else {
tmp->prev->next = tmp;
}
+ _size++;
}
sllnode<_Tp> * erase(sllnode<_Tp> * node) {
sllnode<_Tp> *next = node->next;
delete node;
+ _size--;
return next;
}
_Tp back() {
return tail->val;
}
-
+ uint size() {
+ return _size;
+ }
SNAPSHOTALLOC;
private:
sllnode<_Tp> *head;
sllnode<_Tp> *tail;
+ uint _size;
};
#define VECTOR_DEFCAP 8
-typedef unsigned int uint;
template<typename type>
class ModelVector {