summaryrefslogtreecommitdiffhomepage
path: root/src/handle-pool.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/handle-pool.hpp')
-rw-r--r--src/handle-pool.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/handle-pool.hpp b/src/handle-pool.hpp
new file mode 100644
index 00000000..da7a2538
--- /dev/null
+++ b/src/handle-pool.hpp
@@ -0,0 +1,36 @@
+#pragma once
+#include "compat/defs.hpp"
+#include <cr/Array.h>
+#include <cr/Pointer.h>
+
+namespace floormat::Handle {
+
+template<typename Obj, uint32_t PageSize> class Page;
+
+template<typename Obj, uint32_t PageSize>
+class Pool
+{
+ friend class Handle<Obj, PageSize>;
+
+ static Pointer<Pool<Obj, PageSize>> make_pool();
+ static Page<Obj, PageSize>& find_page();
+
+ Array<Pointer<Page<Obj, PageSize>>> pages;
+ size_t next_page_offset = 0;
+
+ static Pointer<Pool<Obj, PageSize>> pool = make_pool();
+
+public:
+ fm_DECLARE_DELETED_COPY_MOVE_ASSIGNMENTS(Pool);
+
+ explicit Pool();
+ ~Pool() noexcept;
+
+ template<typename... Xs>
+ requires requires (Xs&&... xs) {
+ Obj{forward<Xs>(xs)...};
+ }
+ static Handle<Obj, PageSize> make_object(Xs&&... xs);
+};
+
+} // namespace floormat::Handle