5#ifndef BITCOIN_TEST_UTIL_POOLRESOURCETESTER_H
6#define BITCOIN_TEST_UTIL_POOLRESOURCETESTER_H
44 template <std::
size_t MAX_BLOCK_SIZE_BYTES, std::
size_t ALIGN_BYTES>
47 auto sizes = std::vector<std::size_t>();
50 while (ptr !=
nullptr) {
52 const auto*
ptr_ = ptr;
57 sizes.push_back(size);
65 template <std::
size_t MAX_BLOCK_SIZE_BYTES, std::
size_t ALIGN_BYTES>
78 template <std::
size_t MAX_BLOCK_SIZE_BYTES, std::
size_t ALIGN_BYTES>
86 while (ptr !=
nullptr) {
88 const auto*
ptr_ = ptr;
101 std::vector<PtrAndBytes>
chunks;
#define ASAN_POISON_MEMORY_REGION(addr, size)
#define ASAN_UNPOISON_MEMORY_REGION(addr, size)
A memory resource similar to std::pmr::unsynchronized_pool_resource, but optimized for node-based con...
size_t ChunkSizeBytes() const
Size in bytes to allocate per chunk, currently hardcoded to a fixed size.
std::array< ListNode *, MAX_BLOCK_SIZE_BYTES/ELEM_ALIGN_BYTES+1 > m_free_lists
Single linked lists of all data that came from deallocating.
std::byte * m_available_memory_it
Points to the beginning of available memory for carving out allocations.
std::byte * m_available_memory_end
Points to the end of available memory for carving out allocations.
static constexpr std::size_t ELEM_ALIGN_BYTES
Internal alignment value.
std::list< std::byte * > m_allocated_chunks
Contains all allocated pools of memory, used to free the data in the destructor.
Helper to get access to private parts of PoolResource.
static void CheckAllDataAccountedFor(const PoolResource< MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &resource)
Once all blocks are given back to the resource, tests that the freelists are consistent:
static std::size_t AvailableMemoryFromChunk(const PoolResource< MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &resource)
How many bytes are still available from the last allocated chunk.
static std::vector< std::size_t > FreeListSizes(const PoolResource< MAX_BLOCK_SIZE_BYTES, ALIGN_BYTES > &resource)
Extracts the number of elements per freelist.
In-place linked list of the allocations, used for the freelist.
PtrAndBytes(const void *p, std::size_t s)
friend bool operator<(PtrAndBytes const &a, PtrAndBytes const &b)
defines a sort ordering by the pointer value
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.