Honeycomb  0.1
Component-Model Framework
SmallAllocator.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2015 NewGamePlus Inc. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
4 #include "Honey/Memory/Pool.h"
5 
6 namespace honey
7 {
8 
11 
14 namespace priv
15 {
16  //hold the pool as a reference so that it's never destroyed, as other static objects depend on it
17  inline MemPool& SmallAllocator_pool() { static MemPool& inst = *SmallAllocator_createSingleton(); return inst; }
18 }
21 template<class T>
23 class SmallAllocator : public MemPoolAllocator<SmallAllocator, T>
24 {
25 public:
26  SmallAllocator() = default;
27  template<class U>
29 
30  static MemPool& pool() { return priv::SmallAllocator_pool(); }
31 };
32 
35 
36 #ifndef SmallAllocator_createSingleton_
39  {
40  return new MemPool(
41  {
42  make_tuple(8, 2000),
43  make_tuple(16, 2000),
44  make_tuple(32, 1000),
45  make_tuple(64, 500),
46  make_tuple(128, 200),
47  make_tuple(256, 100),
48  make_tuple(512, 50)
49  }, "Small"_id);
50  }
51 #endif
52 
54 
55 }
static MemPool & pool()
Definition: SmallAllocator.h:30
AllocatorObject< SmallAllocator > SmallAllocatorObject
Inherit from this class to use the small block allocator.
Definition: SmallAllocator.h:34
Objects that inherit from this class will use Alloc for new/delete ops.
Definition: Allocator.h:129
MemPool allocator.
Definition: Pool.h:288
Memory pool.
Definition: Pool.h:29
Global allocator for small memory blocks. To provide a custom pool define SmallAllocator_createSingle...
Definition: SmallAllocator.h:23
SmallAllocator(const SmallAllocator< U > &)
Definition: SmallAllocator.h:28
MemPool * SmallAllocator_createSingleton()
Default implementation.
Definition: SmallAllocator.h:38
Global Honeycomb namespace.