class nbla::AllocatorMemory

class AllocatorMemory

A RAII class for Memory allocated by a Allocator class.Shared pointer of AllocatorMemory.

At a destructor, the borrowed Memory will be returned to a Allocator instance registered at a constructor.

Public Functions

inline shared_ptr<Memory> memory()

Get a Memory intance owned by this.

inline size_t bytes() const

Get bytes.

See also

Memory::bytes

inline string device_id() const

Get device ID.

inline void *pointer()

Get a raw pointer retaining a memory block defined in a Memory implementation class.

inline const void *const_pointer() const

Get as const.

See also

pointer

NBLA_API AllocatorMemory(shared_ptr<Memory> memory, shared_ptr<Allocator> allocator)

Constructor.

This is called from Allocator::alloc to wrap a Memory instance.

Parameters:
  • memory[in] A Memory instance wrapped.

  • allocator[in] Used to return the wrapped memory to it when this instance is destroyed.

NBLA_API AllocatorMemory()

Constructor.

This is called to create an epmpty instance.

NBLA_API ~AllocatorMemory()

Destructor returns a Memory instance given at a constructor to an allocator.