std::pmr::s...ol_resource(3)
okay bestie, this is the std::pmr::s...ol_resource(3) page from the C++ Standard Libary, and we are gonna make this memory-resource moment make sense π
β¨ NAME β¨
std::pmr::synchronized_pool_resource β std::pmr::synchronized_pool_resource π
π¦ Synopsis π¦
Defined in header <memory_resource>
class synchronized_pool_resource : public std::pmr::memory_resource;
since C++17 β¨
The class std::pmr::synchronized_pool_resource is a general-purpose memory resource class with the following properties, and yes bestie, we're listing every single one π:
- It owns the allocated memory and frees it on destruction, even if
deallocatehas not been called for some of the allocated blocks. π - It consists of a collection of pools that serves requests for different block sizes. Each pool manages a collection of chunks that are then divided into blocks of uniform size. π§
- Calls to
do_allocateare dispatched to the pool serving the smallest blocks accommodating the requested size. π― - Exhausting memory in the pool causes the next allocation request for that pool to allocate an additional chunk of memory from the upstream allocator to replenish the pool. The chunk size obtained increases geometrically. π
- Allocations requests that exceed the largest block size are served from the upstream allocator directly. π
- The largest block size and maximum chunk size may be tuned by passing a
std::pmr::pool_optionsstruct to its constructor. π οΈ
synchronized_pool_resource may be accessed from multiple threads without external synchronization, and may have thread-specific pools to reduce synchronization costs. If the memory resource is only accessed from one thread, unsynchronized_pool_resource is more efficient. That's the iykyk π
β¨
πΈ Member functions πΈ
constructorβ constructs asynchronized_pool_resource(public member function) π«Άdestructor[virtual]β destroys asynchronized_pool_resource, releasing all allocated memory (virtual public member function) πoperator=[deleted]β copy assignment operator is deleted.synchronized_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) πͺ
mwah π β source/version/date vibes: http://cppreference.com, 2024.06.10 π«Ά
π¦ 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