Packages

p

zio

stm

package stm

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

Type Members

  1. type STM[+E, +A] = ZSTM[Any, E, A]
  2. final class TArray[A] extends AnyVal

    Wraps array of TRef and adds methods for convenience.

  3. final class TMap[K, V] extends AnyRef

    Transactional map implemented on top of TRef and TArray.

    Transactional map implemented on top of TRef and TArray. Resolves conflicts via chaining.

  4. final class TPromise[E, A] extends AnyVal
  5. final class TQueue[A] extends AnyRef
  6. final class TReentrantLock extends AnyRef

    A TReentrantLock is a reentrant read/write lock.

    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 managed context, and writeLock, which acquires a write lock in a managed 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.

  7. final class TRef[A] extends AnyRef

    A variable that can be modified as part of a transactional effect.

  8. final class TSemaphore extends AnyVal
  9. final class TSet[A] extends AnyVal

    Transactional set implemented on top of TMap.

  10. final class ZSTM[-R, +E, +A] extends AnyVal

    STM[E, A] represents an effect that can be performed transactionally, resulting in a failure E or a value A.

    STM[E, A] represents an effect that can be performed transactionally, resulting in a failure E or a value A.

    def transfer(receiver: TRef[Int],
                 sender: TRef[Int], much: Int): UIO[Int] =
      STM.atomically {
        for {
          balance <- sender.get
          _       <- STM.check(balance >= much)
          _       <- receiver.update(_ + much)
          _       <- sender.update(_ - much)
          newAmnt <- receiver.get
        } yield newAmnt
      }
    
      val action: UIO[Int] =
        for {
          t <- STM.atomically(TRef.make(0).zip(TRef.make(20000)))
          (receiver, sender) = t
          balance <- transfer(receiver, sender, 1000)
        } yield balance

    Software Transactional Memory is a technique which allows composition of arbitrary atomic operations. It is the software analog of transactions in database systems.

    The API is lifted directly from the Haskell package Control.Concurrent.STM although the implementation does not resemble the Haskell one at all. http://hackage.haskell.org/package/stm-2.5.0.0/docs/Control-Concurrent-STM.html

    STM in Haskell was introduced in: Composable memory transactions, by Tim Harris, Simon Marlow, Simon Peyton Jones, and Maurice Herlihy, in ACM Conference on Principles and Practice of Parallel Programming 2005. https://www.microsoft.com/en-us/research/publication/composable-memory-transactions/

    See also: Lock Free Data Structures using STMs in Haskell, by Anthony Discolo, Tim Harris, Simon Marlow, Simon Peyton Jones, Satnam Singh) FLOPS 2006: Eighth International Symposium on Functional and Logic Programming, Fuji Susono, JAPAN, April 2006 https://www.microsoft.com/en-us/research/publication/lock-free-data-structures-using-stms-in-haskell/

Value Members

  1. object STM
  2. object TArray
  3. object TMap
  4. object TPromise
  5. object TQueue
  6. object TReentrantLock
  7. object TRef
  8. object TSemaphore
  9. object TSet
  10. object ZSTM

Inherited from AnyRef

Inherited from Any

Ungrouped