Method AllocateDisjointedBuffer
AllocateDisjointedBuffer(ref FixedList64Bytes<ushort>, NativeList<PayloadHandle>)
Allocates a new Disjointed buffer, which includes allocating the individual Payloads that make up the entire buffer.
Declaration
public PayloadHandle AllocateDisjointedBuffer(ref FixedList64Bytes<ushort> payloadSizes, NativeList<PayloadHandle> payloadHandles = default)
Parameters
Type | Name | Description |
---|---|---|
Fixed |
payloadSizes | Set of buffer sizes to allocate for each Payload that comprises the DisjointedBuffer. |
Native |
payloadHandles | Optional list that receives the Payload |
Returns
Type | Description |
---|---|
Payload |
If successful, a valid Payload |
Remarks
A 'Disjointed' buffer is a set of individual Payload buffers that are collectively treated as a single buffer; it's similar to a Jagged Array or can
be thought of as an "array of arrays". Internally, the Disjointed buffer is implemented by a "head" buffer that holds Payload
Disjointed buffers can either be allocated up front via this Method or created from existing Payloads via Create
When using this method, the individual Payload buffers are automatically allocated using the passed in size values. All Payload allocations sizes (including
the head buffer) must fall within the Minimum
IMPORTANT: If any of the allocations (including the head buffer) fail, the entire operation is aborted and any allocated memory is released. However that memory won't be available for new allocations until after it's been reclaimed by a call to Update(). This means, an attempt to allocate too much memory may result in a significant waste of available space causing other allocation requests to fail.
Disjointed buffers are intended for the following scenarios:
- Payload data exceeds the maximum Payload size and must be broken up into multiple pieces
- The entire Payload data size isn't known up front and must be allocated in different stages
- Additional data needs to be "appended" to an existing payload but without needing to completely reallocate a new buffer
In general, Disjointed buffers should be treated as a single allocation and the individual Payloads that make up the buffer should only be used for immediate reading/writing data. It's recommended to follow these guidelines:
- Do not store or pass the individual Payload handles; only the head handle (returned by this method) should be stored
- Do not release the individual payload allocations; all Disjointed memory is released through the head allocation
- Do not call Lock
Payload on individual payload handle; only the head buffer should be lockedBuffer(Payload Handle) - Do not use a given Payload allocation in multiple Disjointed buffers
- Do not use a Disjointed head handle within another Disjointed buffer (unsupported scenario)
NOTE: These rules are not generally not checked nor enforced, and any validation that is performed only occurs when ENABLE_UNITY_COLLECTIONS_CHECKS or UNITY_DOTS_DEBUG is enabled.
AllocateDisjointedBuffer(ref FixedList512Bytes<ushort>, NativeList<PayloadHandle>)
Allocates a new Disjointed buffer, which includes allocating the individual Payloads that make up the entire buffer.
Declaration
public PayloadHandle AllocateDisjointedBuffer(ref FixedList512Bytes<ushort> payloadSizes, NativeList<PayloadHandle> payloadHandles = default)
Parameters
Type | Name | Description |
---|---|---|
Fixed |
payloadSizes | Set of buffer sizes to allocate for each Payload that comprises the DisjointedBuffer. |
Native |
payloadHandles | Optional list that receives the Payload |
Returns
Type | Description |
---|---|
Payload |
If successful, a valid Payload |
AllocateDisjointedBuffer(ref NativeList<ushort>, NativeList<PayloadHandle>)
Allocates a new Disjointed buffer, which includes allocating the individual Payloads that make up the entire buffer.
Declaration
public PayloadHandle AllocateDisjointedBuffer(ref NativeList<ushort> payloadSizes, NativeList<PayloadHandle> payloadHandles = default)
Parameters
Type | Name | Description |
---|---|---|
Native |
payloadSizes | Set of buffer sizes to allocate for each Payload that comprises the DisjointedBuffer. |
Native |
payloadHandles | Optional list that receives the Payload |
Returns
Type | Description |
---|---|
Payload |
If successful, a valid Payload |