Struct AllocatorManager.AllocatorHandle
Represents the allocator function used within an allocator.
Namespace: Unity.Collections
Syntax
public struct AllocatorHandle : AllocatorManager.IAllocator, IDisposable
Fields
Index
This allocator's index into the global table of allocator functions.
Declaration
public ushort Index
Field Value
Type | Description |
---|---|
UInt16 | This allocator's index into the global table of allocator functions. |
Version
This allocator's version number.
Declaration
public ushort Version
Field Value
Type | Description |
---|---|
UInt16 | This allocator's version number. |
Remarks
An allocator function is uniquely identified by its combination of Index and Version together: each index has a version number that starts at 0; the version number is incremented each time the allocator is invalidated. Only the lower 15 bits of Version is in use because when allocator version is larger than 0x7FFF, allocator.ToAllocator returns a negative value which causes problem when comparing to Allocator.None.
Properties
Function
For internal use only.
Declaration
public readonly AllocatorManager.TryFunction Function { get; }
Property Value
Type | Description |
---|---|
AllocatorManager.TryFunction | For internal use only. |
Implements
Handle
This handle.
Declaration
public AllocatorManager.AllocatorHandle Handle { get; set; }
Property Value
Type | Description |
---|---|
AllocatorManager.AllocatorHandle | This handle. |
Implements
IsCustomAllocator
Check whether this allocator is a custom allocator.
Declaration
public readonly bool IsCustomAllocator { get; }
Property Value
Type | Description |
---|---|
Boolean | True if this AllocatorHandle is a custom allocator. |
Implements
Remarks
The AllocatorHandle is a custom allocator if its Index is larger or equal to FirstUserIndex
.
ToAllocator
Retrieve the Allocator associated with this allocator handle.
Declaration
public readonly Allocator ToAllocator { get; }
Property Value
Type | Description |
---|---|
Allocator | The Allocator retrieved. |
Implements
Value
The Index cast to int.
Declaration
public readonly int Value { get; }
Property Value
Type | Description |
---|---|
Int32 | The Index cast to int. |
Methods
AllocateBlock<T>(Int32)
Allocates a block with this allocator function.
Declaration
public AllocatorManager.Block AllocateBlock<T>(int items)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Int32 | items | The number of values to allocate for. |
Returns
Type | Description |
---|---|
AllocatorManager.Block | The allocated block. |
Type Parameters
Name | Description |
---|---|
T | The type of value to allocate for. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the allocator is not valid or if the allocation failed. |
Dispose()
Dispose the allocator.
Declaration
public void Dispose()
Try(ref AllocatorManager.Block)
Tries to allocate the block with this allocator.
Declaration
public int Try(ref AllocatorManager.Block block)
Parameters
Type | Name | Description |
---|---|---|
AllocatorManager.Block | block | The block to allocate. |
Returns
Type | Description |
---|---|
Int32 | 0 if successful. Otherwise, returns an error code. |
Implements
TryAllocateBlock<T>(out AllocatorManager.Block, Int32)
Allocates a block from this allocator.
Declaration
public int TryAllocateBlock<T>(out AllocatorManager.Block block, int items)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
AllocatorManager.Block | block | Outputs the allocated block. |
Int32 | items | The number of values to allocate for. |
Returns
Type | Description |
---|---|
Int32 | 0 if successful. Otherwise, returns the error code from the allocator function. |
Type Parameters
Name | Description |
---|---|
T | The type of value to allocate for. |
Operators
Implicit(Allocator to AllocatorManager.AllocatorHandle)
Returns the AllocatorHandle of an allocator.
Declaration
public static implicit operator AllocatorManager.AllocatorHandle(Allocator a)
Parameters
Type | Name | Description |
---|---|---|
Allocator | a | The Allocator to copy. |
Returns
Type | Description |
---|---|
AllocatorManager.AllocatorHandle | The AllocatorHandle of an allocator. |