std::experi...ol_resource(3)
π std::experi...ol_resource(3) β the C++ Standard Library glow-up
okay so bestie, we're in the C++ Standard Library today and this page is literally about std::experimental::pmr::unsynchronized_pool_resource π (yes the title gets truncated in the header, that's just the man page being extra, the full name is right there in the NAME section, no cap).
β¨ NAME β¨
std::experimental::pmr::unsynchronized_pool_resource β like, the same thing again, that's it, that's the name π
πΈ SYNOPSIS πΈ
Defined in header <experimental/memory_resource>:
class unsynchronized_pool_resource : public memory_resource; (library fundamentals TS)
π¦ DESCRIPTION π¦
So std::experimental::pmr::unsynchronized_pool_resource is a general-purpose memory resource class, and it's giving very organized-girlie energy. Here's the whole vibe check of what it does π
- It owns the memory it allocates and frees it on destruction β even if
deallocatewas never called for some of those allocated blocks. She cleans up after herself, periodt. - It's basically a collection of pools, and each pool serves requests for different block sizes. Every pool manages a bunch of chunks, and each chunk gets divided into blocks of uniform size. Very drawer-organizer-core π§Ί
- Calls to
do_allocateget dispatched to the pool that serves the smallest blocks that can accommodate the requested size. smallest fit, always. - When a pool runs out of memory, the next allocation request for that pool grabs an additional chunk of memory from the upstream allocator to replenish it. And the chunk size it gets grows geometrically β she escalates π
- Allocation requests that exceed the largest block size get served from the upstream allocator directly. no middleman.
- The largest block size and maximum chunk size can be tuned by passing a
std::experimental::pmr::pool_optionsstruct to its constructor. customization is self care π
β οΈ okay this part is important bestie:unsynchronized_pool_resourceis not thread-safe, and it cannot be accessed from multiple threads simultaneously. Usesynchronized_pool_resourceif you need access from multiple threads. fr fr do not ignore this one π
π MEMBER FUNCTIONS π
- constructor β constructs an
unsynchronized_pool_resource(public member function) - destructor
[virtual]β destroys anunsynchronized_pool_resource, releasing all allocated memory (virtual public member function) - operator=
[deleted]β the copy assignment operator is deleted;unsynchronized_pool_resourceis not copy assignable (public member function)
π PUBLIC MEMBER FUNCTIONS π
- release β release all allocated memory (public member function)
- upstream_resource β returns a pointer to the upstream memory resource (public member function)
- options β returns the options that control the pooling behavior of this resource (public member function)
π«Ά PROTECTED MEMBER FUNCTIONS π«Ά
- do_allocate
[virtual]β allocate memory (virtual protected member function) - do_deallocate
[virtual]β return memory to the pool (virtual protected member function) - do_is_equal
[virtual]β compare for equality with anothermemory_resource(virtual protected member function)
π CATEGORY π
- Noindexed pages
okay that's the whole page, you ate that bestie β β this was served up fresh from http://cppreference.com, version 2024.06.10, dated the same. mwah π go allocate something iconic π¦π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms