Non-owning reference to a memory resource that is itself a resource: copying the ref shares the underlying resource rather than copying it.
More...
|
| | ResourceRef (R &resource) |
| | Constructs a ref borrowing resource.
|
| void * | allocate (size_t bytes, size_t alignment) |
| | Synchronous pair, forwarding to the referenced resource.
|
| void | deallocate (void *p, size_t bytes, size_t alignment) |
| template<class S = R, std::enable_if_t< is_async_resource< S >::value, int > = 0> |
| void * | allocate_async (size_t bytes, size_t alignment, cudaStream_t stream) |
| | Stream-ordered pair, present only when R models AsyncResource, so a ref over a synchronous resource does not misreport its tier.
|
| template<class S = R, std::enable_if_t< is_async_resource< S >::value, int > = 0> |
| void | deallocate_async (void *p, size_t bytes, size_t alignment, cudaStream_t stream) |
| | Stream-ordered pair, present only when R models AsyncResource, so a ref over a synchronous resource does not misreport its tier.
|
template<class R>
struct nanovdb::cuda::ResourceRef< R >
Non-owning reference to a memory resource that is itself a resource: copying the ref shares the underlying resource rather than copying it.
- Template Parameters
-
| R | the referenced resource type |
Types that hold their resource by value – cuda::Buffer, matching cuda::buffer – select their ownership semantics by what is placed in that slot: a concrete resource is owned as a copy, while a ResourceRef borrows. This is the same division cuda::mr draws between any_resource (owning) and resource_ref (borrowing), and the same shape as std::pmr::polymorphic_allocator over memory_resource*. Use it when a resource is stateful or long-lived and a container must allocate through that instance rather than a copy of it.
- Warning
- The referenced resource must outlive every use of this ref and of all copies of it, including any container holding one.