Struct UnsafeStream | Collections | 0.11.0-preview.17
docs.unity3d.com
    Show / Hide Table of Contents

    Struct UnsafeStream

    A deterministic data streaming supporting parallel reading and parallel writing. Allows you to write different types or arrays into a single stream.

    Namespace: Unity.Collections.LowLevel.Unsafe
    Syntax
    public struct UnsafeStream : IDisposable

    Constructors

    UnsafeStream(Int32, Allocator)

    Constructs a new UnsafeStream using the specified type of memory allocation.

    Declaration
    public UnsafeStream(int foreachCount, Allocator allocator)
    Parameters
    Type Name Description
    Int32 foreachCount
    Allocator allocator

    Properties

    ForEachCount

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

    IsCreated

    Reports whether memory for the container is allocated.

    Declaration
    public bool IsCreated { get; }
    Property Value
    Type Description
    Boolean

    True if this container object's internal storage has been allocated.

    Remarks

    Note that the container storage is not created if you use the default constructor. You must specify at least an allocation type to construct a usable container.

    Methods

    AsReader()

    Returns reader instance.

    Declaration
    public UnsafeStream.Reader AsReader()
    Returns
    Type Description
    UnsafeStream.Reader

    Reader instance

    AsWriter()

    Returns writer instance.

    Declaration
    public UnsafeStream.Writer AsWriter()
    Returns
    Type Description
    UnsafeStream.Writer

    Writer instance

    Count()

    The current number of items in the container.

    Declaration
    public int Count()
    Returns
    Type Description
    Int32

    The item count.

    Dispose()

    Disposes of this stream and deallocates its memory immediately.

    Declaration
    public void Dispose()

    Dispose(JobHandle)

    Safely disposes of this container and deallocates its memory when the jobs that use it have completed.

    Declaration
    public JobHandle Dispose(JobHandle inputDeps)
    Parameters
    Type Name Description
    JobHandle inputDeps

    All jobs spawned will depend on this JobHandle.

    Returns
    Type Description
    JobHandle

    A new job handle containing the prior handles as well as the handle for the job that deletes the container.

    Remarks

    You can call this function dispose of the container immediately after scheduling the job. Pass the JobHandle returned by the Job.Schedule method using the jobHandle parameter so the job scheduler can dispose the container after all jobs using it have run.

    IsEmpty()

    Reports whether container is empty.

    Declaration
    public bool IsEmpty()
    Returns
    Type Description
    Boolean

    True if this container empty.

    ScheduleConstruct(out UnsafeStream, NativeArray<Int32>, JobHandle, Allocator)

    Schedule job to construct a new UnsafeStream using the specified type of memory allocation.

    Declaration
    public static JobHandle ScheduleConstruct(out UnsafeStream stream, NativeArray<int> lengthFromIndex0, JobHandle dependency, Allocator allocator)
    Parameters
    Type Name Description
    UnsafeStream stream
    NativeArray<Int32> lengthFromIndex0
    JobHandle dependency

    All jobs spawned will depend on this JobHandle.

    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Returns
    Type Description
    JobHandle

    ScheduleConstruct<T>(out UnsafeStream, NativeList<T>, JobHandle, Allocator)

    Schedule job to construct a new UnsafeStream using the specified type of memory allocation.

    Declaration
    public static JobHandle ScheduleConstruct<T>(out UnsafeStream stream, NativeList<T> forEachCountFromList, JobHandle dependency, Allocator allocator)
        where T : struct
    Parameters
    Type Name Description
    UnsafeStream stream
    NativeList<T> forEachCountFromList
    JobHandle dependency

    All jobs spawned will depend on this JobHandle.

    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Returns
    Type Description
    JobHandle
    Type Parameters
    Name Description
    T

    ToNativeArray<T>(Allocator)

    Copies stream data into NativeArray.

    Declaration
    public NativeArray<T> ToNativeArray<T>(Allocator allocator)
        where T : struct
    Parameters
    Type Name Description
    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Returns
    Type Description
    NativeArray<T>

    A new NativeArray, allocated with the given strategy and wrapping the stream data.

    Type Parameters
    Name Description
    T

    The type of value.

    Remarks

    The array is a copy of stream data.

    In This Article
    • Constructors
      • UnsafeStream(Int32, Allocator)
    • Properties
      • ForEachCount
      • IsCreated
    • Methods
      • AsReader()
      • AsWriter()
      • Count()
      • Dispose()
      • Dispose(JobHandle)
      • IsEmpty()
      • ScheduleConstruct(out UnsafeStream, NativeArray<Int32>, JobHandle, Allocator)
      • ScheduleConstruct<T>(out UnsafeStream, NativeList<T>, JobHandle, Allocator)
      • ToNativeArray<T>(Allocator)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023