summaryrefslogtreecommitdiff
path: root/AK/Queue.h
AgeCommit message (Collapse)Author
2021-09-10AK+Everywhere: Reduce the number of template parameters of IntrusiveListAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-07-14AK: Avoid pagefaults when repeatedly enqueing/dequeing items in a QueueGunnar Beutner
When repeatedly enqueing and dequeing a single item in a Queue we end up faulting in all the pages for the underlying Vector. This is a performance issue - especially where the element type is large.
2021-07-14AK: Avoid allocations for the Queue classGunnar Beutner
Previously the Queue class used a SinglyLinkedList to manage its queue segments. This changes the Queue class to use the IntrusiveList class instead which saves us one allocation per segment.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-01-31Queue: Correctly pass args to enqueueLenny Maiorani
Problem: - Using regular functions rather than function templates results in the arguments not being deduced. This then requires the same function to be written multiple times and for `move` to be used rather than `forward`. Solution: - Collapse multiple function overloads to a single function template with a deduced argument. This allows the argument to be a forwarding reference and bind to either an l-value or r-value and forward the value.
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2020-09-25Meta+AK: Make clang-format-10 cleanBen Wiederhake
2020-02-25AK: Make Queue use size_t for its sizeAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-11-03AK: Allow overriding the Queue segment size with a template parameterAndreas Kling
2019-11-03AK: Add Queue::head()Andreas Kling
This returns a const T& for the first element in the queue, without dequeuing it.
2019-07-28AK: Add Queue::clear() to clear out a Queue.Andreas Kling
2019-07-13AK: Add Queue::enqueue(const T&).Andreas Kling
2019-06-15AK: Add a simple Queue<T> class.Andreas Kling
The underlying data structure is a singly-linked list of Vector<T>. We never shift any of the vector contents around, but we batch the memory allocations into 1000-element segments.