mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[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);
|
||||
t->handle_release();
|
||||
}
|
||||
m_threads.clear();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ public:
|
||||
class iterator
|
||||
{
|
||||
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) {}
|
||||
inline T& operator*() { assert(node); return node->items[index]; }
|
||||
inline iterator & operator++() { incr(); return *this; }
|
||||
@@ -36,10 +38,7 @@ public:
|
||||
};
|
||||
|
||||
deque() : m_first(0), m_next(N) {}
|
||||
~deque() {
|
||||
while (!m_list.empty())
|
||||
delete m_list.pop_front();
|
||||
}
|
||||
~deque() { clear(); }
|
||||
|
||||
inline void push_front(const T& item) {
|
||||
if (!m_first) { // need a new block at the start
|
||||
@@ -110,6 +109,13 @@ public:
|
||||
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 end() { return iterator {m_list.back(), m_next}; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user