docs.unity3d.com
    Show / Hide Table of Contents

    Struct SpinLockReadWrite

    Burst-friendly synchronization primitive that supports read lock and exclusive (write) lock

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    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
    IDisposable.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()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023