|
NumericAL
A header-only C++20 lexer built on REAL
|
Blocks freed and kept for the next buffer that fits one: a fresh block's pages are each faulted in and zeroed by the system at their first write, on the thread that writes it (glibc hands a large freed block back to the system unless the next request is of its very size; macOS's allocator likewise), where a kept block's are already in place. Places blocks at most, each under Largest bytes, the newest kept: a block freed while every place is taken frees the one kept longest. The first allocation one fits, with no more than half of it unused, takes it. Blocks aligned on Alignment.
More...
#include <buffer.hpp>
Classes | |
| struct | block |
Public Member Functions | |
| kept_blocks ()=default | |
| ~kept_blocks () | |
| Frees the blocks still kept. | |
| kept_blocks (const kept_blocks &)=delete | |
| kept_blocks & | operator= (const kept_blocks &)=delete |
| kept_blocks (kept_blocks &&)=delete | |
| kept_blocks & | operator= (kept_blocks &&)=delete |
| std::byte * | take (std::size_t bytes, std::size_t &got) noexcept |
A kept block of at least bytes and under twice as many, its size in got; nullptr if none. | |
| bool | keep (std::byte *start, std::size_t bytes) noexcept |
Keeps the block at start of bytes if it is under largest, in place of the block kept longest when every place is taken (that one freed): the blocks of the sizes in use stay, those of a size no longer asked for leave. False, the block not kept, if it is too large. | |
| void | clear () noexcept |
| Frees every block kept (numerical::release_memory). | |
Static Public Member Functions | |
| static kept_blocks & | shared () |
| The process's blocks, never destroyed: a buffer of static storage may be freed after any destructor. | |
Static Public Attributes | |
| static constexpr std::size_t | alignment {Alignment} |
| The alignment of a block. | |
| static constexpr std::size_t | largest {Largest} |
| The bytes from which a freed block is freed at once, not kept. | |
Private Attributes | |
| std::mutex | lock_ |
| std::array< block, Places > | kept_ {} |
| std::size_t | kept_count_ {0} |
Blocks freed and kept for the next buffer that fits one: a fresh block's pages are each faulted in and zeroed by the system at their first write, on the thread that writes it (glibc hands a large freed block back to the system unless the next request is of its very size; macOS's allocator likewise), where a kept block's are already in place. Places blocks at most, each under Largest bytes, the newest kept: a block freed while every place is taken frees the one kept longest. The first allocation one fits, with no more than half of it unused, takes it. Blocks aligned on Alignment.
Definition at line 96 of file buffer.hpp.
|
default |
|
inline |
Frees the blocks still kept.
Definition at line 116 of file buffer.hpp.
|
delete |
|
delete |
|
inlinenoexcept |
Frees every block kept (numerical::release_memory).
Definition at line 182 of file buffer.hpp.
|
inlinenoexcept |
Keeps the block at start of bytes if it is under largest, in place of the block kept longest when every place is taken (that one freed): the blocks of the sizes in use stay, those of a size no longer asked for leave. False, the block not kept, if it is too large.
Definition at line 153 of file buffer.hpp.
|
delete |
|
delete |
|
inlinestatic |
The process's blocks, never destroyed: a buffer of static storage may be freed after any destructor.
Definition at line 107 of file buffer.hpp.
|
inlinenoexcept |
A kept block of at least bytes and under twice as many, its size in got; nullptr if none.
Definition at line 131 of file buffer.hpp.
|
staticconstexpr |
The alignment of a block.
Definition at line 101 of file buffer.hpp.
|
private |
Definition at line 206 of file buffer.hpp.
|
private |
Definition at line 207 of file buffer.hpp.
|
staticconstexpr |
The bytes from which a freed block is freed at once, not kept.
Definition at line 104 of file buffer.hpp.
|
private |
Definition at line 205 of file buffer.hpp.