Struct SpinLockReadWrite
Burst-friendly synchronization primitive that supports read lock and exclusive (write) lock
Implements
Inherited Members
Namespace: Unity.Logging
Assembly: Unity.Logging.dll
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 bool IsCreated { get; }
Property Value
Type | Description |
---|---|
bool |
Locked
True if exclusively locked
Declaration
public bool Locked { get; }
Property Value
Type | Description |
---|---|
bool |
LockedForRead
True if read locked
Declaration
public bool LockedForRead { get; }
Property Value
Type | Description |
---|---|
bool |
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()
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()