bit::memory
Public Member Functions | Friends | List of all members
bit::memory::freelist Class Reference

A simple freelist that uses intrusive pointers inside raw memory. More...

#include <freelist.hpp>

Public Member Functions

constexpr freelist () noexcept
 Default constructs an empty freelist.
 
 freelist (freelist &&other) noexcept=default
 Move-assigns a freelist from an existing freelist.
 
 freelist (const freelist &other)=delete
 
freelistoperator= (freelist &&other)=delete
 
freelistoperator= (const freelist &other)=delete
 
void swap (freelist &other) noexcept
 Swaps this with another block cache. More...
 
bool empty () const noexcept
 Returns whether or not this memory_block_cache is empty. More...
 
std::size_t size () const noexcept
 Returns the number of entries in this freelist. More...
 
void clear ()
 Empties the freelist cache.
 
void * request () noexcept
 Requests raw memory from the freelist, if any exists. More...
 
void steal (freelist &other) noexcept
 Steals raw meory from an existing freelist.
 
void store (void *p) noexcept
 Stores raw memory into this freelist. More...
 

Friends

bool operator== (const freelist &, const freelist &) noexcept
 

Detailed Description

A simple freelist that uses intrusive pointers inside raw memory.

This is dissimilar from the memory_block_cache in that it does not store each block sie in the freelist; it only knows of the pointers. The semantics, ownership, and valdity of the pointers must all be managed from outside

Definition at line 53 of file freelist.hpp.

Member Function Documentation

◆ empty()

bool bit::memory::freelist::empty ( ) const
noexcept

Returns whether or not this memory_block_cache is empty.

Returns
true if this memory_block_cache is empty, false otherwise

◆ request()

void* bit::memory::freelist::request ( )
noexcept

Requests raw memory from the freelist, if any exists.

The size of the returned instance is not known to the freelist

Returns
pointer to memory, if it exists

◆ size()

std::size_t bit::memory::freelist::size ( ) const
noexcept

Returns the number of entries in this freelist.

Returns
the number of entries in this freelist

◆ store()

void bit::memory::freelist::store ( void *  p)
noexcept

Stores raw memory into this freelist.

Precondition
The pointer p must point to memory of at least sizeof(void*) bytes, and must be suitably aligned to support pointer types.
Parameters
ppointer to the raw memory to store

◆ swap()

void bit::memory::freelist::swap ( freelist other)
noexcept

Swaps this with another block cache.

Parameters
otherthe other memory_block_cache to swap with

The documentation for this class was generated from the following file: