Struct SpinLockReadWrite
Burst-friendly synchronization primitive that supports read lock and exclusive (write) lock
Inherited Members
Namespace: Unity.Logging
Syntax
public struct SpinLockReadWrite : IDisposable
Constructors
SpinLockReadWrite(Allocator)
Allocates the spinlock
Declaration
public SpinLockReadWrite(Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
Allocator | allocator | Allocator to use |
Properties
IsCreated
True if was created
Declaration
public readonly bool IsCreated { get; }
Property Value
Type | Description |
---|---|
Boolean |
Locked
True if exclusively locked
Declaration
public readonly bool Locked { get; }
Property Value
Type | Description |
---|---|
Boolean |
LockedForRead
True if read locked
Declaration
public readonly bool LockedForRead { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Dispose()
Enters the exclusive mode (so no other is holding the lock) and destroys it - so nobody can enter it
Declaration
public void Dispose()
Implements
Lock()
Enters the exclusive lock
Declaration
public void Lock()
LockRead()
Enters the read lock (multiple read locks allowed in parallel, but no exclusive)
Declaration
public void LockRead()
MustBeExclusivelyLocked()
Throws if not in the exclusive lock
Declaration
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
[Conditional("UNITY_DOTS_DEBUG")]
public void MustBeExclusivelyLocked()
Exceptions
Type | Condition |
---|---|
Exception | If SpinLock is not exclusively locked |
MustBeReadLocked()
Throws if not in the read lock
Declaration
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
[Conditional("UNITY_DOTS_DEBUG")]
public void MustBeReadLocked()
Exceptions
Type | Condition |
---|---|
Exception | If SpinLock is not read locked |
Unlock()
Exits the exclusive lock
Declaration
public void Unlock()
UnlockRead()
Exits the read lock
Declaration
public void UnlockRead()