summaryrefslogtreecommitdiffstats
path: root/raul
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-24 02:07:30 +0000
committerDavid Robillard <d@drobilla.net>2008-11-24 02:07:30 +0000
commitc894b33088b9c64316b747f05abc5dd0f868f7bf (patch)
treeeafa980ab2fb856354c2a8dab062db4c51dcd505 /raul
parentf94295cd8431e0489c244c2e41ae4bdfb6d5e6b0 (diff)
downloadraul-c894b33088b9c64316b747f05abc5dd0f868f7bf.tar.gz
raul-c894b33088b9c64316b747f05abc5dd0f868f7bf.tar.bz2
raul-c894b33088b9c64316b747f05abc5dd0f868f7bf.zip
Use lists instead of ringbuffers for event queue - remove upper limit on event queue size and related warnings on big patch load.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@1776 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul')
-rw-r--r--raul/List.hpp22
-rw-r--r--raul/ListImpl.hpp36
2 files changed, 52 insertions, 6 deletions
diff --git a/raul/List.hpp b/raul/List.hpp
index 05fdb1e..a3f63a2 100644
--- a/raul/List.hpp
+++ b/raul/List.hpp
@@ -69,11 +69,17 @@ public:
};
- List() : _size(0), _end_iter(this), _const_end_iter(this) {
+ List(size_t size=0, Node* head=NULL, Node* tail=NULL)
+ : _size(size)
+ , _end_iter(this)
+ , _const_end_iter(this)
+ {
+ _head = head;
+ _tail = tail;
_end_iter._listnode = NULL;
_const_end_iter._listnode = NULL;
}
-
+
~List();
void push_back(Node* elem); ///< Realtime Safe
@@ -106,6 +112,9 @@ public:
inline bool operator==(const const_iterator& iter) const;
inline bool operator==(const iterator& iter) const;
+ inline typename List<T>::Node* node() { return _listnode; }
+ inline const typename List<T>::Node* node() const { return _listnode; }
+
friend class List<T>;
private:
@@ -126,7 +135,7 @@ public:
inline bool operator!=(const const_iterator& iter) const;
inline bool operator==(const iterator& iter) const;
inline bool operator==(const const_iterator& iter) const;
-
+
friend class List<T>;
friend class List<T>::const_iterator;
@@ -135,6 +144,7 @@ public:
typename List<T>::Node* _listnode;
};
+ void chop_front(List<T>& front, size_t front_size, Node* new_head);
Node* erase(const iterator iter);
@@ -147,6 +157,9 @@ public:
T& front() { return *begin(); }
const T& front() const { return *begin(); }
+ Node* head() { return _head.get(); }
+ const Node* head() const { return _head.get(); }
+
private:
AtomicPtr<Node> _head;
AtomicPtr<Node> _tail; ///< writer only
@@ -158,6 +171,7 @@ private:
} // namespace Raul
+#endif // RAUL_LIST_HPP
+
#include "ListImpl.hpp"
-#endif // RAUL_LIST_HPP
diff --git a/raul/ListImpl.hpp b/raul/ListImpl.hpp
index ec1fde4..815afcb 100644
--- a/raul/ListImpl.hpp
+++ b/raul/ListImpl.hpp
@@ -109,7 +109,6 @@ List<T>::push_back(T& elem)
*
* This operation is fast ( O(1) ).
* The appended list is not safe to use concurrently with this call.
- *
* The appended list will be empty after this call.
*
* Thread safe (may be called while another thread is reading the list).
@@ -123,6 +122,9 @@ List<T>::append(List<T>& list)
Node* const my_tail = _tail.get();
Node* const other_head = list._head.get();
Node* const other_tail = list._tail.get();
+
+ assert((my_head && my_tail) || (!my_head && !my_tail));
+ assert((other_head && other_tail) || (!other_head && !other_tail));
// Appending to an empty list
if (my_head == NULL && my_tail == NULL) {
@@ -178,7 +180,6 @@ List<T>::erase(const iterator iter)
Node* const n = iter._listnode;
if (n) {
-
Node* const prev = n->prev();
Node* const next = n->next();
@@ -199,10 +200,41 @@ List<T>::erase(const iterator iter)
--_size;
}
+ assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
return n;
}
+template <typename T>
+void
+List<T>::chop_front(List<T>& front, size_t front_size, Node* new_head)
+{
+ assert(new_head != _head.get());
+ assert((front._head.get() && front._tail.get()) || (!front._head.get() && !front._tail.get()));
+ assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
+ if (!new_head) {
+ assert(front_size == static_cast<size_t>(_size.get()));
+ front._size = _size;
+ front._head = _head;
+ front._tail = _tail;
+ _size = 0;
+ _head = NULL;
+ _tail = NULL;
+ } else {
+ front._size = front_size;
+ front._head = _head;
+ front._tail = new_head->_prev;
+ if (new_head->prev())
+ new_head->prev()->_next = NULL;
+ _head = new_head;
+ new_head->_prev = NULL;
+ _size -= front_size;
+ }
+ assert((front._head.get() && front._tail.get()) || (!front._head.get() && !front._tail.get()));
+ assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
+}
+
+
//// Iterator stuff ////
template <typename T>