diff --git a/kernel/src/memory/Heap.cpp b/kernel/src/memory/Heap.cpp index 77e5ac24..e0abe5c8 100644 --- a/kernel/src/memory/Heap.cpp +++ b/kernel/src/memory/Heap.cpp @@ -26,7 +26,7 @@ static constexpr usize BLOCK_DEAD = 0xdeaddeaddeaddead; static constexpr usize MINIMUM_PAGES_PER_ALLOCATION = 4; -struct HeapBlock : DoublyLinkedListNode +struct HeapBlock : LinkedListNode { usize req_size; usize full_size; @@ -38,7 +38,7 @@ static_assert(sizeof(HeapBlock) == 48UL); static const isize HEAP_BLOCK_SIZE = 48; -static DoublyLinkedList heap; +static LinkedList heap; static Result allocate_pages(usize count) { diff --git a/kernel/src/thread/Scheduler.cpp b/kernel/src/thread/Scheduler.cpp index d961edf0..7e0f7acd 100644 --- a/kernel/src/thread/Scheduler.cpp +++ b/kernel/src/thread/Scheduler.cpp @@ -178,9 +178,9 @@ namespace Scheduler if (!g_current->ticks_left) switch_task(regs); } - DoublyLinkedList check_for_dying_threads() + LinkedList check_for_dying_threads() { - DoublyLinkedList result; + LinkedList result; g_threads.delayed_for_each([&](Thread* thread) { if (thread->state == ThreadState::Dying) diff --git a/kernel/src/thread/Scheduler.h b/kernel/src/thread/Scheduler.h index b0c686ac..10a47534 100644 --- a/kernel/src/thread/Scheduler.h +++ b/kernel/src/thread/Scheduler.h @@ -20,7 +20,7 @@ namespace Scheduler void invoke(Registers* regs); - DoublyLinkedList check_for_dying_threads(); + LinkedList check_for_dying_threads(); } extern "C" void kernel_yield(); diff --git a/kernel/src/thread/Thread.cpp b/kernel/src/thread/Thread.cpp index 48540869..22cdebac 100644 --- a/kernel/src/thread/Thread.cpp +++ b/kernel/src/thread/Thread.cpp @@ -4,7 +4,7 @@ static Atomic g_next_id; -DoublyLinkedList g_threads; +LinkedList g_threads; void Thread::init() { diff --git a/kernel/src/thread/Thread.h b/kernel/src/thread/Thread.h index aac36c41..6e8cc628 100644 --- a/kernel/src/thread/Thread.h +++ b/kernel/src/thread/Thread.h @@ -18,7 +18,7 @@ enum class ThreadState Dying }; -struct Thread : public DoublyLinkedListNode +struct Thread : public LinkedListNode { Registers regs; @@ -60,4 +60,4 @@ bool is_in_kernel(Registers* regs); Result new_thread(); -extern DoublyLinkedList g_threads; \ No newline at end of file +extern LinkedList g_threads; \ No newline at end of file diff --git a/luna/include/luna/LinkedList.h b/luna/include/luna/LinkedList.h index 0ea2ecc3..63b858b8 100644 --- a/luna/include/luna/LinkedList.h +++ b/luna/include/luna/LinkedList.h @@ -9,11 +9,11 @@ template inline Option nonnull_or_error(T* ptr) return ptr; } -template class DoublyLinkedList; +template class LinkedList; -template class DoublyLinkedListNode +template class LinkedListNode { - using SelfType = DoublyLinkedListNode; + using SelfType = LinkedListNode; private: SelfType* m_next_node; @@ -57,14 +57,14 @@ template class DoublyLinkedListNode this->m_next_node = start_node; } - friend class DoublyLinkedList; + friend class LinkedList; }; -template class DoublyLinkedList +template class LinkedList { - using Node = DoublyLinkedListNode; + using Node = LinkedListNode; - static_assert(IsBaseOf, T>); + static_assert(IsBaseOf, T>); public: void append(T* ptr) @@ -155,13 +155,13 @@ template 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 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 void delayed_for_each(Callback callback) { @@ -173,27 +173,27 @@ template 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 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 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 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 void consume(Callback callback) {