TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AreaMemoryManager.h
Go to the documentation of this file.
1 
14 #ifndef G3D_AreaMemoryManager_h
15 #define G3D_AreaMemoryManager_h
16 
17 #include "G3D/platform.h"
18 #include "G3D/g3dmath.h"
19 #include "G3D/Array.h"
20 #include "G3D/MemoryManager.h"
21 
22 namespace G3D {
23 
33 private:
34 
35  class Buffer {
36  private:
38  size_t m_size;
39  size_t m_used;
40 
41  public:
42 
43  Buffer(size_t size);
44 
45  ~Buffer();
46 
48  void* alloc(size_t s);
49  };
50 
51  size_t m_sizeHint;
52 
55 
56  AreaMemoryManager(size_t sizeHint);
57 
58 public:
59 
60  typedef shared_ptr<AreaMemoryManager> Ref;
61 
67  static AreaMemoryManager::Ref create(size_t sizeHint = 10 * 1024 * 1024);
68 
71 
72  size_t bytesAllocated() const;
73 
76  virtual void* alloc(size_t s);
77 
79  virtual void free(void* x);
80 
81  virtual bool isThreadsafe() const;
82 
87  void deallocateAll();
88 };
89 
91 }
92 
93 #endif
virtual bool isThreadsafe() const
Definition: AreaMemoryManager.cpp:40
Buffer(size_t size)
Definition: AreaMemoryManager.cpp:18
static MemoryManager::Ref create()
Definition: MemoryManager.cpp:35
shared_ptr< AreaMemoryManager > Ref
Definition: AreaMemoryManager.h:60
Definition: AABox.h:25
Dynamic 1D array tuned for performance.
Definition: Array.h:95
uint8 * m_first
Definition: AreaMemoryManager.h:37
size_t m_used
Definition: AreaMemoryManager.h:39
size_t m_size
Definition: AreaMemoryManager.h:38
Definition: MemoryManager.h:24
~Buffer()
Definition: AreaMemoryManager.cpp:24
virtual void * alloc(size_t s)
Definition: AreaMemoryManager.cpp:65
virtual void free(void *x)
Definition: AreaMemoryManager.cpp:77
~AreaMemoryManager()
Definition: AreaMemoryManager.cpp:55
size_t m_sizeHint
Definition: AreaMemoryManager.h:51
Array< Buffer * > m_bufferArray
Definition: AreaMemoryManager.h:54
void * alloc(size_t s)
Definition: AreaMemoryManager.cpp:29
size_t bytesAllocated() const
Definition: AreaMemoryManager.cpp:60
Allocates memory in large blocks and then frees it as an area.
Definition: AreaMemoryManager.h:32
uint8_t uint8
Definition: g3dmath.h:164
AreaMemoryManager CoherentAllocator
Definition: AreaMemoryManager.h:90
G3D::int16 x
Definition: Vector2int16.h:37
AreaMemoryManager(size_t sizeHint)
Definition: AreaMemoryManager.cpp:50
Definition: AreaMemoryManager.h:35
void deallocateAll()
Definition: AreaMemoryManager.cpp:82