docs.unity3d.com
    目次を表示する/隠す

    Class IJobParallelForBatchExtensions

    Extension class for the IJobParallelForBatch job type providing custom overloads for scheduling and running.

    Inheritance
    Object
    IJobParallelForBatchExtensions
    Namespace: Unity.Jobs
    Syntax
    public static class IJobParallelForBatchExtensions

    Methods

    EarlyJobInit<T>()

    Gathers and caches reflection data for the internal job system's managed bindings. Unity is responsible for calling this method - don't call it yourself.

    Declaration
    public static void EarlyJobInit<T>()
        where T : struct, IJobParallelForBatch
    Type Parameters
    Name Description
    T
    Remarks

    When the Jobs package is included in the project, Unity generates code to call EarlyJobInit at startup. This allows Burst compiled code to schedule jobs because the reflection part of initialization, which is not compatible with burst compiler constraints, has already happened in EarlyJobInit.

    Note: While the Jobs package code generator handles this automatically for all closed job types, you must register those with generic arguments (like IJobParallelForBatch&lt;MyJobType&lt;T&gt;&gt;) manually for each specialization with [[Unity.Jobs.RegisterGenericJobTypeAttribute]].

    RunBatch<T>(T, Int32)

    Executes the parallel batch job but on the main thread. See IJobParallelForBatchExtensions.ScheduleBatch for more information on how appending is performed.

    Declaration
    public static void RunBatch<T>(this T jobData, int arrayLength)
        where T : struct, IJobParallelForBatch
    Parameters
    Type Name Description
    T jobData

    The job and data to schedule.

    Int32 arrayLength

    Total number of elements to consider when batching.

    Type Parameters
    Name Description
    T

    Job type

    Remarks

    Unlike ScheduleBatch, since the job is running on the main thread no parallelization occurs and thus no indicesPerJobCount batch size is required to be specified.

    RunBatchByRef<T>(ref T, Int32)

    Executes the parallel batch job but on the main thread. See IJobParallelForBatchExtensions.ScheduleBatch for more information on how appending is performed.

    Declaration
    public static void RunBatchByRef<T>(this ref T jobData, int arrayLength)
        where T : struct, IJobParallelForBatch
    Parameters
    Type Name Description
    T jobData

    The job and data to schedule. In this variant, the jobData is passed by reference, which may be necessary for unusually large job structs.

    Int32 arrayLength

    Total number of elements to consider when batching.

    Type Parameters
    Name Description
    T

    Job type

    ScheduleBatch<T>(T, Int32, Int32, JobHandle)

    Schedules a job that will execute the parallel batch job for all arrayLength elements in batches of indicesPerJobCount. The Execute() method for Job T will be provided the start index and number of elements to safely operate on. In cases where indicesPerJobCount is not a multiple of arrayLength, the count provided to the Execute method of Job T will be smaller than the indicesPerJobCount specified here.

    Declaration
    public static JobHandle ScheduleBatch<T>(this T jobData, int arrayLength, int indicesPerJobCount, JobHandle dependsOn = default(JobHandle))
        where T : struct, IJobParallelForBatch
    Parameters
    Type Name Description
    T jobData

    The job and data to schedule.

    Int32 arrayLength

    Total number of elements to consider when batching.

    Int32 indicesPerJobCount

    Number of elements to consider in a single parallel batch.

    JobHandle dependsOn

    Dependencies are used to ensure that a job executes on workerthreads after the dependency has completed execution. Making sure that two jobs reading or writing to same data do not run in parallel.

    Returns
    Type Description
    JobHandle

    JobHandle The handle identifying the scheduled job. Can be used as a dependency for a later job or ensure completion on the main thread.

    Type Parameters
    Name Description
    T

    Job type

    ScheduleBatchByRef<T>(ref T, Int32, Int32, JobHandle)

    Schedules a job that will execute the parallel batch job for all arrayLength elements in batches of indicesPerJobCount. The Execute() method for Job T will be provided the start index and number of elements to safely operate on. In cases where indicesPerJobCount is not a multiple of arrayLength, the count provided to the Execute method of Job T will be smaller than the indicesPerJobCount specified here.

    Declaration
    public static JobHandle ScheduleBatchByRef<T>(this ref T jobData, int arrayLength, int indicesPerJobCount, JobHandle dependsOn = default(JobHandle))
        where T : struct, IJobParallelForBatch
    Parameters
    Type Name Description
    T jobData

    The job and data to schedule. In this variant, the jobData is passed by reference, which may be necessary for unusually large job structs.

    Int32 arrayLength

    Total number of elements to consider when batching.

    Int32 indicesPerJobCount

    Number of elements to consider in a single parallel batch.

    JobHandle dependsOn

    Dependencies are used to ensure that a job executes on workerthreads after the dependency has completed execution. Making sure that two jobs reading or writing to same data do not run in parallel.

    Returns
    Type Description
    JobHandle

    JobHandle The handle identifying the scheduled job. Can be used as a dependency for a later job or ensure completion on the main thread.

    Type Parameters
    Name Description
    T

    Job type

    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)