A* Pathfinding Project  4.3.4
The A* Pathfinding Project for Unity 3D
JobDependencyTracker Struct Reference

Automatic dependency tracking for the Unity Job System. More...

Detailed Description

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(ref tracker);
var job2 = new ExampleJob {
someData = data
}.Schedule(ref tracker);
// job2 automatically depends on job1 because they both require read/write access to the data array
}
See also
Pathfinding.Util.IJobExtensions

Classes

struct  JobDispose
 
struct  JobRaycastCommandDummy
 
struct  NativeArraySlot
 

Public Member Functions

JobHandle DeferDispose< T > (NativeArray< T > data)
 Disposes the native array after all the current jobs are finished with it. More...
 
void Dispose ()
 Diposes this tracker. More...
 
JobHandle ScheduleBatch (NativeArray< UnityEngine.RaycastCommand > commands, NativeArray< UnityEngine.RaycastHit > results, int minCommandsPerJob)
 Schedules a raycast batch command. More...
 

Package Functions

void JobReadsFrom (JobHandle job, long nativeArrayHash)
 
void JobWritesTo (JobHandle job, long nativeArrayHash)
 

Package Attributes

List< NativeArraySlotslots
 

Properties

JobHandle AllWritesDependency [get]
 JobHandle that represents a dependency for all jobs. More...
 

Member Function Documentation

◆ DeferDispose< T >()

JobHandle DeferDispose< T > ( NativeArray< T >  data)

Disposes the native array after all the current jobs are finished with it.

Type Constraints
T :struct 

◆ Dispose()

void Dispose ( )

Diposes this tracker.

This will pool all used lists which makes the GC happy.

◆ JobReadsFrom()

void JobReadsFrom ( JobHandle  job,
long  nativeArrayHash 
)
package

◆ JobWritesTo()

void JobWritesTo ( JobHandle  job,
long  nativeArrayHash 
)
package

◆ ScheduleBatch()

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.

Member Data Documentation

◆ slots

List<NativeArraySlot> slots
package

Property Documentation

◆ AllWritesDependency

JobHandle AllWritesDependency
get

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.


The documentation for this struct was generated from the following file: