Class RWLock

Public

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 #UnlockAfter on 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

Read ()

Aquire a read lock on the main thread.

Public
ReadSync ()

Aquire a read lock on the main thread.

Public
Write ()

Aquire a write lock on the main thread.

Public
WriteSync ()

Aquire a write lock on the main thread.

Public

Private/Protected Members

AddPendingAsync ()
Private
AddPendingSync ()
Private
RemovePendingAsync ()
Private
RemovePendingSync ()
Private
lastRead
Private
lastWrite
Private