|
VLink
2.0.0
A high-performance communication middleware
|
PMR adapter that lets standard pmr-aware containers allocate through vlink::MemoryPool.
更多...
#include <memory>命名空间 | |
| vlink | |
| vlink::MemoryResource | |
Fallback shim when <memory_resource> is unavailable. | |
函数 | |
| template<typename T , typename... Args> | |
| std::shared_ptr< T > | vlink::MemoryResource::make_shared (Args &&... args) |
Fallback make_shared forwarding to std::make_shared. 更多... | |
| template<typename T , typename... Args> | |
| std::unique_ptr< T > | vlink::MemoryResource::make_unique (Args &&... args) |
Fallback make_unique forwarding to std::make_unique. 更多... | |
PMR adapter that lets standard pmr-aware containers allocate through vlink::MemoryPool.
vlink::MemoryResource derives from std::pmr::memory_resource and forwards each request onto an owned (or shared) vlink::MemoryPool. This bridges the standard polymorphic allocator machinery with VLink's tiered pool.
| Aspect | std::pmr::new_delete_resource | vlink::MemoryResource |
|---|---|---|
| Backing allocator | global operator new / delete | vlink::MemoryPool (per-tier free lists) |
| Allocation footprint | unpredictable per-call | bounded per-tier; pooled |
| Concurrent allocs | global allocator scaling | per-tier locking, low contention |
| Bypass mode | not applicable | empty tier list yields pass-through |
| Maintenance | not applicable | trim releases idle chunks |
MemoryResource(), MemoryResource(int) and MemoryResource(const Config&) each heap-allocate a private MemoryPool and own it for the lifetime of the resource.MemoryResource::global_instance returns a process-wide singleton that wraps MemoryPool::global_instance; the resource is not deleted by the destructor.do_allocate throws std::bad_alloc when the underlying pool returns nullptr, satisfying the pmr contract. Equality is identity over the bound MemoryPool object.