Public
Automatic dependency tracking for the Unity Job System.
Uses reflection to find the [ReadOnly] and [WriteOnly] attributes on job data struct fields. These are used to automatically figure out dependencies between jobs.
A job that reads from an array depends on the last job that wrote to that array. A job that writes to an array depends on the last job that wrote to the array as well as all jobs that read from the array.
struct ExampleJob : IJob {
public NativeArray<int> someData;
public void Execute () {
// Do something
}
}
void Start () {
var tracker = new JobDependencyTracker();
var data = new NativeArray<int>(100, Allocator.TempJob);
var job1 = new ExampleJob {
someData = data
}.Schedule(tracker);
var job2 = new ExampleJob {
someData = data
}.Schedule(tracker);
// job2 automatically depends on job1 because they both require read/write access to the data array
}
Inner Types
Public Methods
NativeArray<T>
NewNativeArray<T>
(
int | length | |
Allocator | allocator | |
NativeArrayOptions | options=NativeArrayOptions.ClearMemory | |
)
void
Persist<T>
(
)
Makes the given array not be disposed when this tracker is disposed.
This is useful if you want to keep the array around after the tracker has been disposed. The array will still be tracked for the purposes of automatic dependency management.
JobHandle
ScheduleBatch
(
NativeArray<UnityEngine.RaycastCommand> | commands | |
NativeArray<UnityEngine.RaycastHit> | results | |
int | minCommandsPerJob | |
)
Schedules a raycast batch command.
Like RaycastCommand.ScheduleBatch, but dependencies are tracked automatically.
JobHandle
ScheduleBatch
(
NativeArray<UnityEngine.OverlapCapsuleCommand> | commands | |
NativeArray<UnityEngine.ColliderHit> | results | |
int | minCommandsPerJob | |
)
Schedules an overlap capsule batch command.
Like OverlapCapsuleCommand.ScheduleBatch, but dependencies are tracked automatically.
JobHandle
ScheduleBatch
(
NativeArray<UnityEngine.OverlapSphereCommand> | commands | |
NativeArray<UnityEngine.ColliderHit> | results | |
int | minCommandsPerJob | |
)
Schedules an overlap sphere batch command.
Like OverlapSphereCommand.ScheduleBatch, but dependencies are tracked automatically.
void
SetLinearDependencies
(
)
Disable dependency tracking and just run jobs one after the other.
This may be faster in some cases since dependency tracking has some overhead.
void
Track<T>
(
NativeArray<T> | array | |
bool | initialized=true | |
)
Public Variables
JobHandle
AllWritesDependency
JobHandle that represents a dependency for all jobs.
All native arrays that are written (and have been tracked by this tracker) to will have their final results in them when the returned job handle is complete.
bool
forceLinearDependencies
Private/Protected Members
void
Dispose
()
Disposes this tracker.
This will pool all used lists which makes the GC happy.
NoteIt is necessary to call this method to avoid memory leaks if you are using the DeferDispose method. But it's a good thing to do otherwise as well. It is automatically called if you are using the ObjectPool<T>.Release method.
void
JobReadsFrom
(
JobHandle | job | |
long | nativeArrayHash | |
int | jobHash | |
)
void
JobWritesTo
(
JobHandle | job | |
long | nativeArrayHash | |
int | jobHash | |
)
void IAstarPooledObject.
OnEnterPool
()
NativeArray<JobHandle>
dependenciesScratchBuffer
bool
supportsMultithreading