Class IJobParallelForDeferExtensions
Extension class for the IJobParallelForDefer job type providing custom overloads for scheduling and running.
Namespace: Unity.Jobs
Assembly: Unity.Collections.dll
Syntax
public static class IJobParallelForDeferExtensions
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, IJobParallelForDefer
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 IJobParallelForDefer<MyJobType<T>>) manually for each specialization with [[Unity.Jobs.RegisterGenericJobTypeAttribute]].
ScheduleByRef<T>(ref T, int*, int, JobHandle)
Schedule the job for execution on worker threads. forEachCount is a pointer to the number of iterations, when dependsOn has completed. This API is unsafe, it is recommended to use the NativeList based Schedule method instead.
Declaration
public static JobHandle ScheduleByRef<T>(this ref T jobData, int* forEachCount, int innerloopBatchCount, JobHandle dependsOn = default) where T : struct, IJobParallelForDefer
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. |
int* | forEachCount | *forEachCount is used as the iteration count. |
int | innerloopBatchCount | Granularity in which workstealing is performed. A value of 32, means the job queue will steal 32 iterations and then perform them in an efficient inner loop. |
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 |
ScheduleByRef<T, U>(ref T, NativeList<U>, int, JobHandle)
Schedule the job for execution on worker threads. list.Length is used as the iteration count. Note that it is required to embed the list on the job struct as well.
Declaration
public static JobHandle ScheduleByRef<T, U>(this ref T jobData, NativeList<U> list, int innerloopBatchCount, JobHandle dependsOn = default) where T : struct, IJobParallelForDefer where U : unmanaged
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. |
NativeList<U> | list | list.Length is used as the iteration count. |
int | innerloopBatchCount | Granularity in which workstealing is performed. A value of 32, means the job queue will steal 32 iterations and then perform them in an efficient inner loop. |
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 |
U | List element type |
Schedule<T>(T, int*, int, JobHandle)
Schedule the job for execution on worker threads. forEachCount is a pointer to the number of iterations, when dependsOn has completed. This API is unsafe, it is recommended to use the NativeList based Schedule method instead.
Declaration
public static JobHandle Schedule<T>(this T jobData, int* forEachCount, int innerloopBatchCount, JobHandle dependsOn = default) where T : struct, IJobParallelForDefer
Parameters
Type | Name | Description |
---|---|---|
T | jobData | The job and data to schedule. |
int* | forEachCount | *forEachCount is used as the iteration count. |
int | innerloopBatchCount | Granularity in which workstealing is performed. A value of 32, means the job queue will steal 32 iterations and then perform them in an efficient inner loop. |
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 |
Schedule<T, U>(T, NativeList<U>, int, JobHandle)
Schedule the job for execution on worker threads. list.Length is used as the iteration count. Note that it is required to embed the list on the job struct as well.
Declaration
public static JobHandle Schedule<T, U>(this T jobData, NativeList<U> list, int innerloopBatchCount, JobHandle dependsOn = default) where T : struct, IJobParallelForDefer where U : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T | jobData | The job and data to schedule. |
NativeList<U> | list | list.Length is used as the iteration count. |
int | innerloopBatchCount | Granularity in which workstealing is performed. A value of 32, means the job queue will steal 32 iterations and then perform them in an efficient inner loop. |
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 |
U | List element type |