Class/Object

zio.stm

TReentrantLock

Related Docs: object TReentrantLock | package stm

Permalink

final class TReentrantLock extends AnyRef

A TReentrantLock is a reentrant read/write lock. Multiple readers may all concurrently acquire read locks. Only one writer is allowed to acquire a write lock at any given time. Read locks may be upgraded into write locks. A fiber that has a write lock may acquire other write locks or read locks.

The two primary methods of this structure are readLock, which acquires a read lock in a scoped context, and writeLock, which acquires a write lock in a scoped context.

Although located in the STM package, there is no need for locks within STM transactions. However, this lock can be quite useful in effectful code, to provide consistent read/write access to mutable state; and being in STM allows this structure to be composed into more complicated concurrent structures that are consumed from effectful code.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TReentrantLock
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. lazy val acquireRead: USTM[Int]

    Permalink

    Acquires a read lock.

    Acquires a read lock. The transaction will suspend until no other fiber is holding a write lock. Succeeds with the number of read locks held by this fiber.

  5. lazy val acquireWrite: USTM[Int]

    Permalink

    Acquires a write lock.

    Acquires a write lock. The transaction will suspend until no other fibers are holding read or write locks. Succeeds with the number of write locks held by this fiber.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def fiberReadLocks: USTM[Int]

    Permalink

    Retrieves the number of acquired read locks for this fiber.

  11. def fiberWriteLocks: USTM[Int]

    Permalink

    Retrieves the number of acquired write locks for this fiber.

  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. def lock(implicit trace: Trace): ZIO[Scope, Nothing, Int]

    Permalink

    Just a convenience method for applications that only need reentrant locks, without needing a distinction between readers / writers.

    Just a convenience method for applications that only need reentrant locks, without needing a distinction between readers / writers.

    See writeLock.

  17. def locked: USTM[Boolean]

    Permalink

    Determines if any fiber has a read or write lock.

  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. def readLock(implicit trace: Trace): ZIO[Scope, Nothing, Int]

    Permalink

    Obtains a read lock in a scoped context.

  22. def readLocked: USTM[Boolean]

    Permalink

    Determines if any fiber has a read lock.

  23. def readLocks: USTM[Int]

    Permalink

    Retrieves the total number of acquired read locks.

  24. lazy val releaseRead: USTM[Int]

    Permalink

    Releases a read lock held by this fiber.

    Releases a read lock held by this fiber. Succeeds with the outstanding number of read locks held by this fiber.

  25. lazy val releaseWrite: USTM[Int]

    Permalink

    Releases a write lock held by this fiber.

    Releases a write lock held by this fiber. Succeeds with the outstanding number of write locks held by this fiber.

  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def withLock[R, E, A](zio: ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

    Permalink

    Runs the specified workflow with a lock.

  32. def withReadLock[R, E, A](zio: ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

    Permalink

    Runs the specified workflow with a read lock.

  33. def withWriteLock[R, E, A](zio: ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

    Permalink

    Runs the specified workflow with a write lock.

  34. def writeLock(implicit trace: Trace): ZIO[Scope, Nothing, Int]

    Permalink

    Obtains a write lock in a scoped context.

  35. def writeLocked: USTM[Boolean]

    Permalink

    Determines if a write lock is held by some fiber.

  36. def writeLocks: USTM[Int]

    Permalink

    Computes the number of write locks held by fibers.

Inherited from AnyRef

Inherited from Any

Ungrouped