Class Freelist

Nested Relationships

Class Documentation

class wrench::Freelist

This type is a simple, single-threaded free-list implementation. It is essentially just a singly linked-list over an arena from which the free list nodes are allocated from.

Public Functions

Freelist() = default

Default constructor.

~Freelist() noexcept

Default destructor, resets head pointer.

Freelist(const void *start, const void *end, size_t element_size, size_t alignment) noexcept

Constructor to initialize the freelist with the start and end of the arena from which elements can be stored.

Parameters
  • start: The start of the arena.

  • end: The end of the arena.

  • element_size: The size of the elements in the freelist.

  • alignment: The alignment of the elements.

Freelist(Freelist &&other) noexcept = default

Move constructor to move other to this freelist.

Parameters
  • other: The other freelist to move.

auto operator= (Freelist &&other) noexcept -> Freelist &=default

Move assignment to move other to this freelist.

Parameters
  • other: The other freelist to move.

Freelist(const Freelist&) = delete

Copy constructor deleted since the freelist can’t be copied.

auto operator= (const Freelist &) -> Freelist &=delete

Copy assignment deleted since the freelist can’t be copied.

auto pop_front () noexcept -> void *

Pops the most recently added element from the list, and returns it.

auto push_front (void *ptr) noexcept -> void

Pushes a new element onto the front of the list.

Parameters
  • ptr: The pointer to the element to push onto the list.

Public Static Attributes

constexpr bool resettable = false

Specifies that the freelist is not resettable.