WPILibC++ 2025.3.2
Loading...
Searching...
No Matches
memory_pool_type.hpp
Go to the documentation of this file.
1// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
2// SPDX-License-Identifier: Zlib
3
4#ifndef WPI_MEMORY_MEMORY_POOL_TYPE_HPP_INCLUDED
5#define WPI_MEMORY_MEMORY_POOL_TYPE_HPP_INCLUDED
6
7/// \file
8/// The \c PoolType tag types.
9
10#include <type_traits>
11
12#include "detail/free_list.hpp"
14#include "config.hpp"
15
16namespace wpi
17{
18 namespace memory
19 {
20 /// Tag type defining a memory pool optimized for nodes.
21 /// It does not support array allocations that great and may trigger a growth even if there is enough memory.
22 /// But it is the fastest pool type.
23 /// \ingroup memory_allocator
24 struct node_pool : WPI_EBO(std::true_type)
25 {
27 };
28
29 /// Tag type defining a memory pool optimized for arrays.
30 /// It keeps the nodes ordered inside the free list and searches the list for an appropriate memory block.
31 /// Array allocations are still pretty slow, if the array gets big enough it can get slower than \c new.
32 /// Node allocations are still fast, unless there is deallocation in random order.
33 /// \note Use this tag type only if you really need to have a memory pool!
34 /// \ingroup memory_allocator
35 struct array_pool : WPI_EBO(std::true_type)
36 {
38 };
39
40 /// Tag type defining a memory pool optimized for small nodes.
41 /// The free list is intrusive and thus requires that each node has at least the size of a pointer.
42 /// This tag type does not have this requirement and thus allows zero-memory-overhead allocations of small nodes.
43 /// It is a little bit slower than \ref node_pool and does not support arrays.
44 /// \ingroup memory_allocator
45 struct small_node_pool : WPI_EBO(std::false_type)
46 {
48 };
49 } // namespace memory
50} // namespace wpi
51
52#endif // WPI_MEMORY_MEMORY_POOL_TYPE_HPP_INCLUDED
Definition free_list.hpp:24
Definition small_free_list.hpp:48
Configuration macros.
ordered_free_memory_list array_free_memory_list
Definition free_list.hpp:221
free_memory_list node_free_memory_list
Definition free_list.hpp:220
Memory namespace.
Definition heap_allocator.hpp:20
Foonathan namespace.
Definition ntcore_cpp.h:26
Tag type defining a memory pool optimized for arrays.
Definition memory_pool_type.hpp:36
Tag type defining a memory pool optimized for nodes.
Definition memory_pool_type.hpp:25
Tag type defining a memory pool optimized for small nodes.
Definition memory_pool_type.hpp:46