std::pmr::u...ol_resource(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

Okay so this is the std::pmr::u...ol_resource(3) page from the C++ Standard Library manual, bestie, and we're talking about the absolutely iconic std::pmr::unsynchronized_pool_resource πŸ’–

πŸŽ€ NAME πŸŽ€

std::pmr::unsynchronized_pool_resource β€” yes, that's the class, and the page title is std::pmr::u...ol_resource(3). Periodt πŸ’…

✨ Synopsis ✨

Defined in header <memory_resource>
class unsynchronized_pool_resource : public
std::pmr::memory_resource;

This class is since C++17 🫢

std::pmr::unsynchronized_pool_resource is a general-purpose memory resource class with these properties, and no we are not skipping any of them:

  • It owns the allocated memory and frees it on destruction, even if deallocate has not been called for some of the allocated blocks. It's giving responsible main character energy πŸ‘‘
  • 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_allocate are dispatched to the pool serving the smallest blocks accommodating the requested size. So it's matching your request to the smallest block that fits, lowkey efficient ✨
  • 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 πŸ“ˆ
  • Allocation requests that exceed the largest block size are served from the upstream allocator directly. No pool for those, they go straight upstairs 😌
  • The largest block size and maximum chunk size may be tuned by passing a std::pmr::pool_options struct to its constructor πŸŽ›οΈ
Okay bestie, important vibe check: unsynchronized_pool_resource is not thread-safe, and cannot be accessed from multiple threads simultaneously; use synchronized_pool_resource if access from multiple threads is required. Do not play yourself πŸ’€

πŸ‘‘ Member functions πŸ‘‘

  • constructor β€” constructs an unsynchronized_pool_resource (public member function)
  • destructor [virtual] β€” destroys an unsynchronized_pool_resource, releasing all allocated memory (virtual public member function)
  • operator= [deleted] β€” copy assignment operator is deleted. unsynchronized_pool_resource is 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 another std::pmr::memory_resource (virtual protected member function)

Source/version and date vibes, bestie: http://cppreference.com, dated 2024.06.10, and the footer title is std::pmr::u...ol_resource(3). Bye bestie πŸ«ΆπŸ’–

πŸ“¦ where this page comes from