docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct AllocatorManager.AllocatorHandle

    Represents the allocator function used within an allocator.

    Implements
    AllocatorManager.IAllocator
    Namespace: Unity.Collections
    Assembly: Unity.Collections.dll
    Syntax
    public struct AllocatorManager.AllocatorHandle : AllocatorManager.IAllocator

    Fields

    Index

    This allocator's index into the global table of allocator functions.

    Declaration
    public ushort Index
    Field Value
    Type Description
    ushort

    This allocator's index into the global table of allocator functions.

    InvalidChildAllocatorIndex

    For internal use only.

    Declaration
    public const int InvalidChildAllocatorIndex = -1
    Field Value
    Type Description
    int

    For internal use only.

    InvalidChildSafetyHandleIndex

    For internal use only.

    Declaration
    public const int InvalidChildSafetyHandleIndex = -1
    Field Value
    Type Description
    int

    For internal use only.

    Version

    This allocator's version number.

    Declaration
    public ushort Version
    Field Value
    Type Description
    ushort

    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.

    IsAutoDispose

    Check whether this allocator will automatically dispose allocations.

    Declaration
    public bool IsAutoDispose { get; }
    Property Value
    Type Description
    bool

    True if allocations made by this AllocatorHandle are not automatically disposed.

    IsCustomAllocator

    Check whether this allocator is a custom allocator.

    Declaration
    public bool IsCustomAllocator { get; }
    Property Value
    Type Description
    bool

    True if this AllocatorHandle is a custom allocator.

    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 Allocator ToAllocator { get; }
    Property Value
    Type Description
    Allocator

    The Allocator retrieved.

    Value

    The Index cast to int.

    Declaration
    public int Value { get; }
    Property Value
    Type Description
    int

    The Index cast to int.

    Methods

    AllocateBlock<T>(int)

    Allocates a block with this allocator function.

    Declaration
    public AllocatorManager.Block AllocateBlock<T>(int items) where T : unmanaged
    Parameters
    Type Name Description
    int 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(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
    int

    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
    bool

    Returns true if both handles are for the same allocator instance at the same version, otherwise false.

    Overrides
    ValueType.Equals(object)

    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
    bool

    Returns true if both handles are for the same allocator instance at the same version, otherwise false.

    Equals(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
    bool

    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
    int

    A unique hash code.

    Overrides
    ValueType.GetHashCode()

    Try(ref 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
    int

    0 if successful. Otherwise, returns an error code.

    TryAllocateBlock<T>(out Block, int)

    Allocates a block from this allocator.

    Declaration
    public int TryAllocateBlock<T>(out AllocatorManager.Block block, int items) where T : unmanaged
    Parameters
    Type Name Description
    AllocatorManager.Block block

    Outputs the allocated block.

    int items

    The number of values to allocate for.

    Returns
    Type Description
    int

    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

    operator ==(AllocatorHandle, 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
    bool

    True if the left-hand side's AllocatorManager.AllocatorHandle is equal to the right-hand side's.

    operator >(AllocatorHandle, 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
    bool

    True if the left-hand side's AllocatorManager.AllocatorHandle is greater than the right-hand side's.

    operator >=(AllocatorHandle, 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
    bool

    True if the left-hand side's AllocatorManager.AllocatorHandle is greater than or equal to the right-hand side's.

    implicit operator AllocatorHandle(Allocator)

    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.

    operator !=(AllocatorHandle, 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
    bool

    True if the left-hand side's AllocatorManager.AllocatorHandle is not equal to the right-hand side's.

    operator <(AllocatorHandle, 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
    bool

    True if the left-hand side's AllocatorManager.AllocatorHandle is less than the right-hand side's.

    operator <=(AllocatorHandle, 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
    bool

    True if the left-hand side's AllocatorManager.AllocatorHandle is less than or equal to the right-hand side's.

    Implements

    AllocatorManager.IAllocator

    Extension Methods

    AllocatorManager.Allocate<T>(ref T, int, int, int)
    AllocatorManager.Register<T>(ref T, bool, bool, int)
    AllocatorManager.UnmanagedUnregister<T>(ref T)
    AllocatorManager.Unregister<T>(ref T)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)