DoublyLinkedList -> LinkedList
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1269a045bd
commit
a11a5dec1f
@ -26,7 +26,7 @@ static constexpr usize BLOCK_DEAD = 0xdeaddeaddeaddead;
|
||||
|
||||
static constexpr usize MINIMUM_PAGES_PER_ALLOCATION = 4;
|
||||
|
||||
struct HeapBlock : DoublyLinkedListNode<HeapBlock>
|
||||
struct HeapBlock : LinkedListNode<HeapBlock>
|
||||
{
|
||||
usize req_size;
|
||||
usize full_size;
|
||||
@ -38,7 +38,7 @@ static_assert(sizeof(HeapBlock) == 48UL);
|
||||
|
||||
static const isize HEAP_BLOCK_SIZE = 48;
|
||||
|
||||
static DoublyLinkedList<HeapBlock> heap;
|
||||
static LinkedList<HeapBlock> heap;
|
||||
|
||||
static Result<HeapBlock*> allocate_pages(usize count)
|
||||
{
|
||||
|
@ -178,9 +178,9 @@ namespace Scheduler
|
||||
if (!g_current->ticks_left) switch_task(regs);
|
||||
}
|
||||
|
||||
DoublyLinkedList<Thread> check_for_dying_threads()
|
||||
LinkedList<Thread> check_for_dying_threads()
|
||||
{
|
||||
DoublyLinkedList<Thread> result;
|
||||
LinkedList<Thread> result;
|
||||
|
||||
g_threads.delayed_for_each([&](Thread* thread) {
|
||||
if (thread->state == ThreadState::Dying)
|
||||
|
@ -20,7 +20,7 @@ namespace Scheduler
|
||||
|
||||
void invoke(Registers* regs);
|
||||
|
||||
DoublyLinkedList<Thread> check_for_dying_threads();
|
||||
LinkedList<Thread> check_for_dying_threads();
|
||||
}
|
||||
|
||||
extern "C" void kernel_yield();
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
static Atomic<u64> g_next_id;
|
||||
|
||||
DoublyLinkedList<Thread> g_threads;
|
||||
LinkedList<Thread> g_threads;
|
||||
|
||||
void Thread::init()
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ enum class ThreadState
|
||||
Dying
|
||||
};
|
||||
|
||||
struct Thread : public DoublyLinkedListNode<Thread>
|
||||
struct Thread : public LinkedListNode<Thread>
|
||||
{
|
||||
Registers regs;
|
||||
|
||||
@ -60,4 +60,4 @@ bool is_in_kernel(Registers* regs);
|
||||
|
||||
Result<Thread*> new_thread();
|
||||
|
||||
extern DoublyLinkedList<Thread> g_threads;
|
||||
extern LinkedList<Thread> g_threads;
|
@ -9,11 +9,11 @@ template <typename T> inline Option<T*> nonnull_or_error(T* ptr)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <typename T> class DoublyLinkedList;
|
||||
template <typename T> class LinkedList;
|
||||
|
||||
template <typename T> class DoublyLinkedListNode
|
||||
template <typename T> class LinkedListNode
|
||||
{
|
||||
using SelfType = DoublyLinkedListNode<T>;
|
||||
using SelfType = LinkedListNode<T>;
|
||||
|
||||
private:
|
||||
SelfType* m_next_node;
|
||||
@ -57,14 +57,14 @@ template <typename T> class DoublyLinkedListNode
|
||||
this->m_next_node = start_node;
|
||||
}
|
||||
|
||||
friend class DoublyLinkedList<T>;
|
||||
friend class LinkedList<T>;
|
||||
};
|
||||
|
||||
template <typename T> class DoublyLinkedList
|
||||
template <typename T> class LinkedList
|
||||
{
|
||||
using Node = DoublyLinkedListNode<T>;
|
||||
using Node = LinkedListNode<T>;
|
||||
|
||||
static_assert(IsBaseOf<DoublyLinkedListNode<T>, T>);
|
||||
static_assert(IsBaseOf<LinkedListNode<T>, T>);
|
||||
|
||||
public:
|
||||
void append(T* ptr)
|
||||
@ -155,13 +155,13 @@ template <typename T> class DoublyLinkedList
|
||||
return nonnull_or_error((T*)extract_node(item)->get_last());
|
||||
}
|
||||
|
||||
// Iterates over the elements of the DoublyLinkedList from start to end, calling callback for every element.
|
||||
// Iterates over the elements of the LinkedList from start to end, calling callback for every element.
|
||||
template <typename Callback> void for_each(Callback callback)
|
||||
{
|
||||
for (Node* node = m_start_node; node; node = node->get_next()) { callback((T*)node); }
|
||||
}
|
||||
|
||||
// Iterates over the elements of the DoublyLinkedList from start to end, calling callback for every element. This
|
||||
// Iterates over the elements of the LinkedList from start to end, calling callback for every element. This
|
||||
// for_each is implemented in such a way that elements can be removed while iterating over it.
|
||||
template <typename Callback> void delayed_for_each(Callback callback)
|
||||
{
|
||||
@ -173,27 +173,27 @@ template <typename T> class DoublyLinkedList
|
||||
}
|
||||
}
|
||||
|
||||
// Iterates over the elements of the DoublyLinkedList from end to start, calling callback for every element.
|
||||
// Iterates over the elements of the LinkedList from end to start, calling callback for every element.
|
||||
template <typename Callback> void for_each_reversed(Callback callback)
|
||||
{
|
||||
for (Node* node = m_end_node; node; node = node->get_last()) { callback((T*)node); }
|
||||
}
|
||||
|
||||
// Iterates over the elements of the DoublyLinkedList from the element after 'start' to end, calling callback for
|
||||
// Iterates over the elements of the LinkedList from the element after 'start' to end, calling callback for
|
||||
// every element.
|
||||
template <typename Callback> void for_each_after(T* start, Callback callback)
|
||||
{
|
||||
for (Node* node = extract_node(start)->m_next_node; node; node = node->get_next()) { callback((T*)node); }
|
||||
}
|
||||
|
||||
// Iterates over the elements of the DoublyLinkedList from the element before 'end' to start, calling callback for
|
||||
// Iterates over the elements of the LinkedList from the element before 'end' to start, calling callback for
|
||||
// every element.
|
||||
template <typename Callback> void for_each_before(T* end, Callback callback)
|
||||
{
|
||||
for (Node* node = extract_node(end)->m_last_node; node; node = node->get_last()) { callback((T*)node); }
|
||||
}
|
||||
|
||||
// Iterates over the elements of the DoublyLinkedList from start to end, removing each element before passing it to
|
||||
// Iterates over the elements of the LinkedList from start to end, removing each element before passing it to
|
||||
// the callback.
|
||||
template <typename Callback> void consume(Callback callback)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user