RWLock

public class RWLock

Represents a reader-writer lock.
Note that this implementation is recursive.

Using a reader-writer lock, multiple treads can lock for reading, if no writer is currently holding the lock.
Only one writer can hold the lock, preventing readers to acquire it.

  • RWLock errors.

    See more

    Declaration

    Swift

    public enum Error: Swift.Error
  • Locing intent.

    See more

    Declaration

    Swift

    public enum Intent
  • Initializer.

    Throws

    RWLock.error on initialization failure.

    Declaration

    Swift

    public init() throws
  • Acquires the lock.

    Seealso

    RWLock.Intent

    Declaration

    Swift

    public func lock( for intent: Intent )
  • Releases the lock.

    Seealso

    RWLock.Intent

    Declaration

    Swift

    public func unlock( for intent: Intent )
  • Tries to acquires the lock.

    Seealso

    RWLock.Intent

    Declaration

    Swift

    public func tryLock( for intent: Intent ) -> Bool

    Return Value

    true if the lock was successfully locked, otherwise false.