26 #ifndef NVNEURAL_SCOPEDMEMORYALLOCATION_H
27 #define NVNEURAL_SCOPEDMEMORYALLOCATION_H
48 : m_pBackend{pBackend}
66 : m_pBackend{pBackend}
73 status = pBackend2->allocateMemoryBlock(&m_hBuffer, bufferSize, pTrackingKey);
89 : m_pBackend{moveFrom.m_pBackend}
90 , m_hBuffer{moveFrom.m_hBuffer}
110 std::swap(m_pBackend, moveFrom.m_pBackend);
111 std::swap(m_hBuffer, moveFrom.m_hBuffer);
116 explicit operator bool()
const
118 return nullptr != m_hBuffer;
constexpr bool failed(NeuralResult result) noexcept
Helper function akin to COM's FAILED() macro.
Definition: CoreTypes.h:289
MemoryHandle__type * MemoryHandle
Opaque typedef used to represent INetworkBackend memory handles.
Definition: CoreTypes.h:626
NeuralResult
NeuralResult is a generic success/failure result type similar to COM HRESULT.
Definition: CoreTypes.h:275
INetworkBackend2 is a revision of INetworkBackend.
Definition: CoreTypes.h:958
INetworkBackend is a runtime-specific interface for CUDA, DirectX, or other system- specific operatio...
Definition: CoreTypes.h:643
virtual NeuralResult allocateMemoryBlock(MemoryHandle *pHandle, size_t byteCount) noexcept=0
Allocates a memory block of the requested size.
virtual NeuralResult freeMemoryBlock(MemoryHandle handle) noexcept=0
Frees a memory block that was allocated with allocateMemoryBlock.
virtual void * getAddressForMemoryBlock(MemoryHandle handle) noexcept=0
Retrieves the raw address corresponding to a MemoryHandle.
Intrusive pointer using IRefObject's reference counting system.
Definition: RefPtr.h:46
RefPtr< TDestinationObject > as() const noexcept
Creates a new reference to the object using the specified interface.
Definition: RefPtr.h:221
static RefPtr fromPointer(TObject *pObject)
Initializes a RefPtr pointing to a specific object.
Definition: RefPtr.h:65
ScopedMemoryAllocation is a helper function for allocating memory blocks from the backend while addin...
Definition: ScopedMemoryAllocation.h:40
MemoryHandle handle() const
Returns the memory handle of the allocated memory block.
Definition: ScopedMemoryAllocation.h:124
void * asPointer()
Returns the pointer to the allocated memory block.
Definition: ScopedMemoryAllocation.h:132
~ScopedMemoryAllocation()
Frees the allocation.
Definition: ScopedMemoryAllocation.h:95
ScopedMemoryAllocation(INetworkBackend *pBackend, size_t bufferSize, const char *pTrackingKey)
Creates a temporary memory allocation, using a network backend, of the requested size and allows trac...
Definition: ScopedMemoryAllocation.h:65
ScopedMemoryAllocation & operator=(ScopedMemoryAllocation &&moveFrom)
Takes ownership of an allocation from another ScopedMemoryAllocation.
Definition: ScopedMemoryAllocation.h:108
ScopedMemoryAllocation(INetworkBackend *pBackend, size_t bufferSize)
Creates a temporary memory allocation using a network backend.
Definition: ScopedMemoryAllocation.h:47
ScopedMemoryAllocation(ScopedMemoryAllocation &&moveFrom)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ScopedMemoryAllocation.h:88