Class RWLock
A simple read/write lock for use with the Unity Job System.
The RW-lock makes the following assumptions:
Only the main thread will call the methods on this lock.
If jobs are to use locked data, you should call Read or Write on the lock and pass the returned JobHandle as a dependency the job, and then call WriteLockAsync.UnlockAfter on the lock object, with the newly scheduled job's handle.
When taking a Read lock, you should only read data, but if you take a Write lock you may modify data.
On the main thread, multiple synchronous write locks may be nested.
You do not need to care about dependencies when calling the ReadSync and WriteSync methods. That's handled automatically for you.
var readLock = AstarPath.active.LockGraphDataForReading();
var handle = new MyJob {
// ...
}.Schedule(readLock.dependency);
readLock.UnlockAfter(handle);
Inner Types
Public Methods
Aquire a read lock on the main thread.
Aquire a read lock on the main thread.
Aquire a write lock on the main thread.
Aquire a write lock on the main thread.