From eb469ff58365517515d73827e70a9519436b5858 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 12 Jul 2024 20:19:25 +0200 Subject: w --- src/handle-page.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/handle-page.hpp (limited to 'src/handle-page.hpp') diff --git a/src/handle-page.hpp b/src/handle-page.hpp new file mode 100644 index 00000000..dee35a9e --- /dev/null +++ b/src/handle-page.hpp @@ -0,0 +1,40 @@ +#pragma once +#include "handle-fwd.hpp" +#include "compat/defs.hpp" +#include +#include + +namespace floormat::Handle { + +template +struct Item +{ + union { Obj object; }; + Handle handle; + uint32_t next; +}; + +template +class Page +{ + friend class Handle; + + std::array, PageSize> storage; + BitArray used_map; // todo replace with a rewrite of std::bitset + uint32_t start_index; + uint32_t used_count = 0; + uint32_t first_free = (uint32_t)-1; + +public: + fm_DECLARE_DELETED_COPY_MOVE_ASSIGNMENTS(Page); + + explicit Page(uint32_t start_index); + ~Page() noexcept; + + [[nodiscard]] Item& allocate(); + void deallocate(Handle obj); + bool is_empty(); + bool is_full(); +}; + +} // namespace floormat::Handle -- cgit v1.2.3