#include <IStreamerTypes.h>
Inherited by AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.
Public Member Functions | |
virtual void | LockAllocator ()=0 |
Called when the Streamer is about to start allocating memory for a request. This will be called multiple times. | |
virtual void | UnlockAllocator ()=0 |
virtual RequestMemoryAllocatorResult | Allocate (u64 minimalSize, u64 recommendeSize, size_t alignment)=0 |
virtual void | Release (void *address)=0 |
RequestMemoryAllocators can be used to provide a mechanic to allow the Streamer to allocate memory right before the request is processed. This can be useful in avoiding having to track memory buffers as these are managed by Streamer until the buffer is claimed. It can also help reduce peak memory if processing data requires temporary buffers as these do not all have to be created upfront. The RequestMemoryAllocator typically outlives the request and a completed request does not mean the allocator isn't still in use as internal processing may still need the allocator. Calls to LockAllocator and UnlockAllocator can be used to keep track of the number of requests that still require processing. The functions in the RequestMemoryAllocator can be called from various threads and may prevent the Streamer from continuing processing. (Similar to the completion callbacks in the requests). It's recommended to spend as little time as possible in these callbacks and defer work to jobs where possible.
|
pure virtual |
Allocate memory for a request.
minimalSize | The minimal amount of memory to reserve. More can be reserved, but not less. |
recommendedSize | The recommended amount of memory to reserve. If this size or more is reserved temporary buffers can be avoided. |
alignment | The minimal recommended memory alignment. If the alignment is less than the recommendation it may force the Streamer to create temporary buffers and do extra processing. |
Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.
|
pure virtual |
Called when the Streamer is about to start allocating memory for a request. This will be called multiple times.
Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.
|
pure virtual |
Releases memory previously allocated by Allocate.
address | The address previously provided by Allocate. |
Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.
|
pure virtual |
Called when the Streamer no longer needs to manage memory for a request. This will be called multiple times. If the number of unlocks matches the number of locks it means the memory allocator is not actively being used by the Streamer.
Implemented in AZ::IO::IStreamerTypes::DefaultRequestMemoryAllocator.