aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-09-30 15:08:18 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-09-30 15:13:23 +0200
commit6959a83b7d7e6a272cfd626fa3799a875460f5ea (patch)
tree241c0086558b63cae3fbd8f28bb748d9c82ca83d
parent8bec65ba723c9c628d934ec02021d5ce09c01105 (diff)
downloadkernel-6959a83b7d7e6a272cfd626fa3799a875460f5ea.tar.xz
kernel-6959a83b7d7e6a272cfd626fa3799a875460f5ea.zip
kstd: add ring_buffer include
-rw-r--r--libs/kstd/kstd/ring_buffer.hpp20
-rw-r--r--libs/kstd/kstd/ring_buffer.tests.cpp17
2 files changed, 37 insertions, 0 deletions
diff --git a/libs/kstd/kstd/ring_buffer.hpp b/libs/kstd/kstd/ring_buffer.hpp
new file mode 100644
index 00000000..0ceb634d
--- /dev/null
+++ b/libs/kstd/kstd/ring_buffer.hpp
@@ -0,0 +1,20 @@
+#ifndef KSTD_RING_BUFFER_HPP
+#define KSTD_RING_BUFFER_HPP
+
+#include <cstddef>
+
+namespace kstd
+{
+
+ //! A fixed-size buffer that will overwrite elements in an LRU manner when full.
+ //!
+ //! @tparam ValueType The type of the values contained in this ring buffer.
+ //! @tparam Capacity The maximum number of elements this ring buffer can hold.
+ template<typename ValueType, std::size_t Capacity>
+ struct ring_buffer
+ {
+ };
+
+} // namespace kstd
+
+#endif \ No newline at end of file
diff --git a/libs/kstd/kstd/ring_buffer.tests.cpp b/libs/kstd/kstd/ring_buffer.tests.cpp
new file mode 100644
index 00000000..3608d5ce
--- /dev/null
+++ b/libs/kstd/kstd/ring_buffer.tests.cpp
@@ -0,0 +1,17 @@
+#include <kstd/ring_buffer.hpp>
+
+#include <catch2/catch_test_macros.hpp>
+
+#include <tuple>
+
+SCENARIO("Ring Buffer initialization and construction", "[ring_buffer]")
+{
+ GIVEN("An empty context")
+ {
+ WHEN("constructing by default")
+ {
+ auto buffer = kstd::ring_buffer<int, 5>{};
+ std::ignore = buffer;
+ }
+ }
+} \ No newline at end of file