[kernel] Empty wait_queue after calling clear()
Bugfix - wait_queue::clear() was not emptying out its util::deque after waking all the threads, so it would just grow forever.
This commit is contained in:
@@ -58,4 +58,5 @@ wait_queue::clear(uint64_t value)
|
|||||||
if (!t->exited()) t->wake(value);
|
if (!t->exited()) t->wake(value);
|
||||||
t->handle_release();
|
t->handle_release();
|
||||||
}
|
}
|
||||||
|
m_threads.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ public:
|
|||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
iterator(node_type *n, size_t i) : node(n), index(i) {}
|
iterator(node_type *n, size_t i) : node(n), index(i) {
|
||||||
|
if (node && index >= N) { node = node->next(); index = 0; }
|
||||||
|
}
|
||||||
iterator(const iterator &o) : node(o.node), index(o.index) {}
|
iterator(const iterator &o) : node(o.node), index(o.index) {}
|
||||||
inline T& operator*() { assert(node); return node->items[index]; }
|
inline T& operator*() { assert(node); return node->items[index]; }
|
||||||
inline iterator & operator++() { incr(); return *this; }
|
inline iterator & operator++() { incr(); return *this; }
|
||||||
@@ -36,10 +38,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
deque() : m_first(0), m_next(N) {}
|
deque() : m_first(0), m_next(N) {}
|
||||||
~deque() {
|
~deque() { clear(); }
|
||||||
while (!m_list.empty())
|
|
||||||
delete m_list.pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void push_front(const T& item) {
|
inline void push_front(const T& item) {
|
||||||
if (!m_first) { // need a new block at the start
|
if (!m_first) { // need a new block at the start
|
||||||
@@ -110,6 +109,13 @@ public:
|
|||||||
return m_list.back()->items[m_next-1];
|
return m_list.back()->items[m_next-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void clear() {
|
||||||
|
while (!m_list.empty())
|
||||||
|
delete m_list.pop_front();
|
||||||
|
m_first = 0;
|
||||||
|
m_next = N;
|
||||||
|
}
|
||||||
|
|
||||||
iterator begin() { return iterator {m_list.front(), m_first}; }
|
iterator begin() { return iterator {m_list.front(), m_first}; }
|
||||||
iterator end() { return iterator {m_list.back(), m_next}; }
|
iterator end() { return iterator {m_list.back(), m_next}; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user