Struct AllocatorManager.AllocatorHandle
Represents the allocator function used within an allocator.
Namespace: Unity.Collections
Syntax
public struct AllocatorHandle : AllocatorManager.IAllocator, IDisposable, IEquatable<AllocatorManager.AllocatorHandle>, IComparable<AllocatorManager.AllocatorHandle>
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
Handle
This handle.
Declaration
public AllocatorManager.AllocatorHandle Handle { get; set; }
Property Value
| Type | Description |
|---|---|
| AllocatorManager.AllocatorHandle | This handle. |
Implements
IsAutoDispose
Check whether this allocator will automatically dispose allocations.
Declaration
public readonly bool IsAutoDispose { get; }
Property Value
| Type | Description |
|---|---|
| Boolean | True if allocations made by this AllocatorHandle are not automatically disposed. |
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. |
CompareTo(AllocatorManager.AllocatorHandle)
Compare this AllocatorManager.AllocatorHandle against a given one
Declaration
public int CompareTo(AllocatorManager.AllocatorHandle other)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | other | The other AllocatorManager.AllocatorHandle to compare to |
Returns
| Type | Description |
|---|---|
| Int32 | Difference between AllocatorManager.AllocatorHandle values |
Dispose()
Dispose the allocator.
Declaration
public void Dispose()
Equals(Object)
AllocatorManager.AllocatorHandle instances are equal if they refer to the same instance at the same version.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | Object containing an AllocatorManager.AllocatorHandle. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if both handles are for the same allocator instance at the same version, otherwise false. |
Overrides
Equals(Allocator)
AllocatorManager.AllocatorHandle instances are equal if they refer to the same instance at the same version.
Declaration
public bool Equals(Allocator other)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | other | Allocator to compare against. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if both handles are for the same allocator instance at the same version, otherwise false. |
Equals(AllocatorManager.AllocatorHandle)
AllocatorManager.AllocatorHandle instances are equal if they refer to the same instance at the same version.
Declaration
public bool Equals(AllocatorManager.AllocatorHandle other)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | other | AllocatorManager.AllocatorHandle to compare against. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if both handles are for the same allocator instance at the same version, otherwise false. |
GetHashCode()
A hash used for comparisons.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 | A unique hash code. |
Overrides
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
Equality(AllocatorManager.AllocatorHandle, AllocatorManager.AllocatorHandle)
Evaluates if one AllocatorManager.AllocatorHandle is equal to the other.
Declaration
public static bool operator ==(AllocatorManager.AllocatorHandle lhs, AllocatorManager.AllocatorHandle rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | lhs | The left-hand side |
| AllocatorManager.AllocatorHandle | rhs | The right-hand side |
Returns
| Type | Description |
|---|---|
| Boolean | True if the left-hand side's AllocatorManager.AllocatorHandle is equal to the right-hand side's. |
GreaterThan(AllocatorManager.AllocatorHandle, AllocatorManager.AllocatorHandle)
Evaluates if one AllocatorManager.AllocatorHandle is greater than the other.
Declaration
public static bool operator>(AllocatorManager.AllocatorHandle lhs, AllocatorManager.AllocatorHandle rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | lhs | The left-hand side |
| AllocatorManager.AllocatorHandle | rhs | The right-hand side |
Returns
| Type | Description |
|---|---|
| Boolean | True if the left-hand side's AllocatorManager.AllocatorHandle is greater than the right-hand side's. |
GreaterThanOrEqual(AllocatorManager.AllocatorHandle, AllocatorManager.AllocatorHandle)
Evaluates if one AllocatorManager.AllocatorHandle is greater than or equal to the other.
Declaration
public static bool operator >=(AllocatorManager.AllocatorHandle lhs, AllocatorManager.AllocatorHandle rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | lhs | The left-hand side |
| AllocatorManager.AllocatorHandle | rhs | The right-hand side |
Returns
| Type | Description |
|---|---|
| Boolean | True if the left-hand side's AllocatorManager.AllocatorHandle is greater than or equal to the right-hand side's. |
Implicit(Allocator to AllocatorManager.AllocatorHandle)
Implicitly convert an Allocator to an AllocatorHandle with its Version being reset to 0.
Declaration
public static implicit operator AllocatorManager.AllocatorHandle(Allocator a)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | a | The Allocator to convert. |
Returns
| Type | Description |
|---|---|
| AllocatorManager.AllocatorHandle | The AllocatorHandle of an allocator. |
Inequality(AllocatorManager.AllocatorHandle, AllocatorManager.AllocatorHandle)
Evaluates if one AllocatorManager.AllocatorHandle is not equal to the other.
Declaration
public static bool operator !=(AllocatorManager.AllocatorHandle lhs, AllocatorManager.AllocatorHandle rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | lhs | The left-hand side |
| AllocatorManager.AllocatorHandle | rhs | The right-hand side |
Returns
| Type | Description |
|---|---|
| Boolean | True if the left-hand side's AllocatorManager.AllocatorHandle is not equal to the right-hand side's. |
LessThan(AllocatorManager.AllocatorHandle, AllocatorManager.AllocatorHandle)
Evaluates if one AllocatorManager.AllocatorHandle is less than the other.
Declaration
public static bool operator <(AllocatorManager.AllocatorHandle lhs, AllocatorManager.AllocatorHandle rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | lhs | The left-hand side |
| AllocatorManager.AllocatorHandle | rhs | The right-hand side |
Returns
| Type | Description |
|---|---|
| Boolean | True if the left-hand side's AllocatorManager.AllocatorHandle is less than the right-hand side's. |
LessThanOrEqual(AllocatorManager.AllocatorHandle, AllocatorManager.AllocatorHandle)
Evaluates if one AllocatorManager.AllocatorHandle is less than or equal to the other.
Declaration
public static bool operator <=(AllocatorManager.AllocatorHandle lhs, AllocatorManager.AllocatorHandle rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| AllocatorManager.AllocatorHandle | lhs | The left-hand side |
| AllocatorManager.AllocatorHandle | rhs | The right-hand side |
Returns
| Type | Description |
|---|---|
| Boolean | True if the left-hand side's AllocatorManager.AllocatorHandle is less than or equal to the right-hand side's. |