Lugdunum  0.1.0
Arena.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdlib>
4 #include <lug/System/Export.hpp>
6 
7 namespace lug {
8 namespace System {
9 namespace Memory {
10 
11 template <
12  class Allocator,
13  class ThreadPolicy,
14  class BoundsCheckingPolicy,
15  class MemoryMarkingPolicy
16 >
17 class Arena {
18 public:
19  Arena() = default;
20  explicit Arena(Area::IArea* area);
21 
22  Arena(const Arena&) = delete;
23  Arena(Arena&&) = default;
24 
25  Arena& operator=(const Arena&) = delete;
26  Arena& operator=(Arena&&) = default;
27 
28  ~Arena() = default;
29 
30  void* allocate(size_t size, size_t alignment, size_t offset, const char* file, size_t line);
31  void free(void* ptr);
32  void reset();
33 
34  Allocator& allocator();
35  const Allocator& allocator() const;
36 
37 private:
38  Allocator _allocator;
39  ThreadPolicy _threadGuard;
40  BoundsCheckingPolicy _boundsChecker;
41  MemoryMarkingPolicy _memoryMarker;
42 };
43 
45 
46 } // Memory
47 } // Sytem
48 } // lug
Arena & operator=(const Arena &)=delete
ThreadPolicy _threadGuard
Definition: Arena.hpp:39
BoundsCheckingPolicy _boundsChecker
Definition: Arena.hpp:40
MemoryMarkingPolicy _memoryMarker
Definition: Arena.hpp:41
Allocator & allocator()
Definition: Arena.inl:83
void free(void *ptr)
Definition: Arena.inl:42
void * allocate(size_t size, size_t alignment, size_t offset, const char *file, size_t line)
Definition: Arena.inl:15