This is a buffer that contains a shared or private pool to either externally or internally managed host memory.
More...
#include <nanovdb/HostBuffer.h>
|
| | HostBuffer (uint64_t bufferSize=0) |
| | Return a full buffer or an empty buffer.
|
| |
| | HostBuffer (HostBuffer &&other) |
| | Move copy-constructor.
|
| |
| | ~HostBuffer () |
| | Custom descructor.
|
| |
| HostBuffer & | operator= (HostBuffer &&other) |
| | Move copy assignment operation.
|
| |
| | HostBuffer (const HostBuffer &)=delete |
| | Disallow copy-construction.
|
| |
| HostBuffer & | operator= (const HostBuffer &)=delete |
| | Disallow copy assignment operation.
|
| |
| void | init (uint64_t bufferSize, void *data=nullptr) |
| | Initialize as a full buffer with the specified size. If data is NULL the memory is internally allocated.
|
| |
| const void * | data () const |
| | Retuns a pointer to the raw memory buffer managed by this allocator.
|
| |
| void * | data () |
| |
| uint64_t | bufferSize () const |
| | Returns the size in bytes associated with this buffer.
|
| |
| uint64_t | size () const |
| |
| uint64_t | poolSize () const |
| | Returns the size in bytes of the memory pool shared with this instance.
|
| |
| bool | isManaged () const |
| | Return true if memory is managed (using std::malloc and std:free) by the shared pool in this buffer. Else memory is assumed to be managed externally.
|
| |
| bool | isEmpty () const |
| | Returns true if this buffer has no memory associated with it.
|
| |
| bool | empty () const |
| |
| bool | isPool () const |
| | Return true if this is a pool, i.e. an empty buffer with a nonempty internal pool, i.e. this->size() == 0 and this->poolSize() != 0.
|
| |
| bool | isFull () const |
| | Return true if the pool exists, is nonempty but has no more available memory.
|
| |
| void | clear () |
| | Clear this buffer so it is empty.
|
| |
| void | reset () |
| | Clears all existing buffers that are registered against the memory pool and resets the pool so it can be reused to create new buffers.
|
| |
| uint64_t | poolUsage () const |
| | Total number of bytes from the pool currently in use by buffers.
|
| |
| void | resizePool (uint64_t poolSize, void *data=nullptr) |
| | resize the pool size. It will attempt to resize the existing memory block, but if that fails a deep copy is performed. If data is not NULL it will be used as new externally managed memory for the pool. All registered buffers are updated so GridHandle::grid might return a new address (if deep copy was performed).
|
| |
|
| static HostBuffer | createPool (uint64_t poolSize, void *data=nullptr) |
| | Return a pool buffer which satisfies: buffer.size == 0, buffer.poolSize() == poolSize, and buffer.data() == nullptr. If data==nullptr, memory for the pool will be allocated.
|
| |
| static HostBuffer | createFull (uint64_t bufferSize, void *data=nullptr) |
| | Return a full buffer which satisfies: buffer.size == bufferSize, buffer.poolSize() == bufferSize, and buffer.data() == data. If data==nullptr, memory for the pool will be allocated.
|
| |
| static HostBuffer | create (uint64_t bufferSize, const HostBuffer *pool=nullptr) |
| | Return a buffer with bufferSize bytes managed by the specified memory pool. If none is provided, i.e. pool == nullptr or pool->poolSize() == 0, one is created with size bufferSize, i.e. a full buffer is returned.
|
| |
This is a buffer that contains a shared or private pool to either externally or internally managed host memory.
- Note
- Terminology: Pool: 0 = buffer.size() < buffer.poolSize() Buffer: 0 < buffer.size() < buffer.poolSize() Full: 0 < buffer.size() = buffer.poolSize() Empty: 0 = buffer.size() = buffer.poolSize()
◆ HostBuffer() [1/3]
Return a full buffer or an empty buffer.
◆ HostBuffer() [2/3]
◆ ~HostBuffer()
◆ HostBuffer() [3/3]
Disallow copy-construction.
◆ bufferSize()
| uint64_t bufferSize |
( |
| ) |
const |
|
inline |
Returns the size in bytes associated with this buffer.
◆ clear()
Clear this buffer so it is empty.
◆ create()
Return a buffer with bufferSize bytes managed by the specified memory pool. If none is provided, i.e. pool == nullptr or pool->poolSize() == 0, one is created with size bufferSize, i.e. a full buffer is returned.
- Exceptions
-
| If | the specified pool has insufficient memory for the requested buffer size. |
◆ createFull()
| HostBuffer createFull |
( |
uint64_t | bufferSize, |
|
|
void * | data = nullptr ) |
|
inlinestatic |
Return a full buffer which satisfies: buffer.size == bufferSize, buffer.poolSize() == bufferSize, and buffer.data() == data. If data==nullptr, memory for the pool will be allocated.
- Exceptions
-
◆ createPool()
| HostBuffer createPool |
( |
uint64_t | poolSize, |
|
|
void * | data = nullptr ) |
|
inlinestatic |
Return a pool buffer which satisfies: buffer.size == 0, buffer.poolSize() == poolSize, and buffer.data() == nullptr. If data==nullptr, memory for the pool will be allocated.
- Exceptions
-
◆ data() [1/2]
◆ data() [2/2]
| const void * data |
( |
| ) |
const |
|
inline |
Retuns a pointer to the raw memory buffer managed by this allocator.
- Warning
- Note that the pointer can be NULL if the allocator was not initialized!
◆ empty()
◆ init()
| void init |
( |
uint64_t | bufferSize, |
|
|
void * | data = nullptr ) |
|
inline |
Initialize as a full buffer with the specified size. If data is NULL the memory is internally allocated.
◆ isEmpty()
Returns true if this buffer has no memory associated with it.
◆ isFull()
Return true if the pool exists, is nonempty but has no more available memory.
◆ isManaged()
Return true if memory is managed (using std::malloc and std:free) by the shared pool in this buffer. Else memory is assumed to be managed externally.
◆ isPool()
Return true if this is a pool, i.e. an empty buffer with a nonempty internal pool, i.e. this->size() == 0 and this->poolSize() != 0.
◆ operator=() [1/2]
Disallow copy assignment operation.
◆ operator=() [2/2]
Move copy assignment operation.
◆ poolSize()
| uint64_t poolSize |
( |
| ) |
const |
|
inline |
Returns the size in bytes of the memory pool shared with this instance.
◆ poolUsage()
| uint64_t poolUsage |
( |
| ) |
const |
|
inline |
Total number of bytes from the pool currently in use by buffers.
◆ reset()
Clears all existing buffers that are registered against the memory pool and resets the pool so it can be reused to create new buffers.
- Exceptions
-
| If | this instance is not empty or contains no pool. |
- Warning
- This method is not thread-safe!
◆ resizePool()
| void resizePool |
( |
uint64_t | poolSize, |
|
|
void * | data = nullptr ) |
|
inline |
resize the pool size. It will attempt to resize the existing memory block, but if that fails a deep copy is performed. If data is not NULL it will be used as new externally managed memory for the pool. All registered buffers are updated so GridHandle::grid might return a new address (if deep copy was performed).
- Note
- This method can be use to resize the memory pool and even change it from internally to externally managed memory or vice versa.
- Exceptions
-
| if | poolSize is less than this->poolUsage() the used memory or allocations fail. |
◆ size()