30 #ifndef BIT_MEMORY_BLOCK_ALLOCATORS_THREAD_LOCAL_BLOCK_ALLOCATOR_HPP 31 #define BIT_MEMORY_BLOCK_ALLOCATORS_THREAD_LOCAL_BLOCK_ALLOCATOR_HPP 33 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 37 #include "detail/named_block_allocator.hpp" 39 #include "../utilities/allocator_info.hpp" 40 #include "../utilities/memory_block.hpp" 41 #include "../utilities/memory_block_cache.hpp" 42 #include "../utilities/owner.hpp" 70 template<std::size_t BlockSize,
71 std::size_t Blocks = 1,
72 std::size_t Align =
alignof(std::max_align_t),
76 static_assert( Blocks > 0,
77 "Must have at least one block" );
78 static_assert( is_power_of_two(Align),
79 "Alignment must be a power of two" );
80 static_assert( Blocks == 1 || BlockSize % Align == 0,
81 "Block size must must be an increment of the block size" );
88 using block_size = std::integral_constant<std::size_t,BlockSize>;
89 using block_alignment = std::integral_constant<std::size_t,Align>;
132 owner<memory_block> allocate_block() noexcept;
137 void deallocate_block( owner<memory_block> block ) noexcept;
147 std::size_t next_block_size()
const noexcept;
162 static constexpr
auto s_storage_size = BlockSize * Blocks;
163 alignas(Align)
static thread_local
char s_storage[s_storage_size];
175 template<std::size_t BlockSize,
176 std::size_t Blocks = 1,
177 std::size_t Align =
alignof(std::max_align_t),
184 #include "detail/thread_local_block_allocator.inl" A cache containing an intrinsically linked list of memory_blocks.
This is a block allocator that distributes blocks of static memory that is local to the specific thre...
This type is used to hold the generic information for a given allocator.