KeptBlocks namespace
KeptBlocks: pooled memory for things a document stores on an author's behalf (handler and component captures, ui.State values) when they don't fit inline.
Blocks come from a BufferPool (fixed size classes, lock-free, any thread), not the heap, so a document that creates and drops thousands of handlers never touches the allocator. The pool is the UI's own, separate from the buffers jobs and messages use. If a size class runs out, the block comes from the heap and is counted: nothing breaks, and the count says to grow the pool (Configure).
Classes
Functions
- auto Configure(std::span<const SizeClass> classes) -> bool
- Size classes, ascending, at most eight. Only valid before first use; returns false after.
- auto Take(size_t bytes) -> void*
- Uninitialised memory. Any thread. Never null.
- void Give(void* memory)
- Return memory from Take. Any thread.
- auto GetUse() -> Use
- What is in use now. Any thread.
-
template<typename T, typename... TArgs>auto Make(TArgs && ... args) -> T*
- Construct a
Tin a block. -
template<typename T>void Destroy(T* made)
- Destroy a
TMake made, and return its block.
Variables
- size_t Alignment constexpr
- Block alignment.
Function documentation
bool GGUI:: KeptBlocks:: Configure(std::span<const SizeClass> classes)
#include <GGUI/Public/UITypes.h>
Size classes, ascending, at most eight. Only valid before first use; returns false after.
void* GGUI:: KeptBlocks:: Take(size_t bytes)
#include <GGUI/Public/UITypes.h>
Uninitialised memory. Any thread. Never null.
void GGUI:: KeptBlocks:: Give(void* memory)
#include <GGUI/Public/UITypes.h>
Return memory from Take. Any thread.
Use GGUI:: KeptBlocks:: GetUse()
#include <GGUI/Public/UITypes.h>
What is in use now. Any thread.
#include <GGUI/Public/UITypes.h>
template<typename T, typename... TArgs>
T* GGUI:: KeptBlocks:: Make(TArgs && ... args)
Construct a T in a block.
#include <GGUI/Public/UITypes.h>
template<typename T>
void GGUI:: KeptBlocks:: Destroy(T* made)
Destroy a T Make made, and return its block.
Variable documentation
size_t GGUI:: KeptBlocks:: Alignment constexpr
#include <GGUI/Public/UITypes.h>
Block alignment.