Packages

  • package root
    Definition Classes
    root
  • package fs2
    Definition Classes
    root
  • package async

    Provides utilities for asynchronous computations.

    Provides utilities for asynchronous computations.

    Definition Classes
    fs2
  • package immutable

    Provides types which allow asynchronous reading (but not writing).

    Provides types which allow asynchronous reading (but not writing).

    Definition Classes
    async
  • package mutable

    Provides types which allow asynchronous reading and writing.

    Provides types which allow asynchronous reading and writing.

    Definition Classes
    async
  • Promise
  • Ref

final class Promise[F[_], A] extends AnyRef

A purely functional synchronisation primitive.

When created, a Promise is empty. It can then be completed exactly once, and never be made empty again.

get on an empty Promise will block until the Promise is completed. get on a completed Promise will always immediately return its content.

complete(a) on an empty Promise will set it to a, and notify any and all readers currently blocked on a call to get. complete(a) on a Promise that's already been completed will not modify its content, and result in a failed F.

Albeit simple, Promise can be used in conjunction with Ref to build complex concurrent behaviour and data structures like queues and semaphores.

Finally, the blocking mentioned above is semantic only, no actual threads are blocked by the implementation.

Source
Promise.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Promise
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to any2stringadd[Promise[F, A]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Promise[F, A], B)
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to ArrowAssoc[Promise[F, A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def cancellableGet: F[(F[A], F[Unit])]

    Like get but returns an F[Unit] that can be used to cancel the subscription.

  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  9. def complete(a: A): F[Unit]

    If this Promise is empty, *synchronously* sets the current value to a, and notifies any and all readers currently blocked on a get.

    If this Promise is empty, *synchronously* sets the current value to a, and notifies any and all readers currently blocked on a get.

    Note that the returned action completes after the reference has been successfully set: use async.fork(r.complete) if you want asynchronous behaviour.

    If this Promise has already been completed, the returned action immediately fails with a Promise.AlreadyCompletedException. In the uncommon scenario where this behaviour is problematic, you can handle failure explicitly using attempt or any other ApplicativeError/MonadError combinator on the returned action.

    Satisfies: Promise.empty[F, A].flatMap(r => r.complete(a) *> r.get) == a.pure[F]

  10. def ensuring(cond: (Promise[F, A]) ⇒ Boolean, msg: ⇒ Any): Promise[F, A]
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to Ensuring[Promise[F, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: (Promise[F, A]) ⇒ Boolean): Promise[F, A]
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to Ensuring[Promise[F, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean, msg: ⇒ Any): Promise[F, A]
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to Ensuring[Promise[F, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean): Promise[F, A]
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to Ensuring[Promise[F, A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to StringFormat[Promise[F, A]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  18. def get: F[A]

    Obtains the value of the Promise, or waits until it has been completed.

  19. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  20. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  21. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  26. def timedGet(timeout: FiniteDuration, scheduler: Scheduler): F[Option[A]]

    Like get but if the Promise has not been completed when the timeout is reached, a None is returned.

  27. def toString(): String
    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  31. def [B](y: B): (Promise[F, A], B)
    Implicit
    This member is added by an implicit conversion from Promise[F, A] to ArrowAssoc[Promise[F, A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Promise[F, A] to any2stringadd[Promise[F, A]]

Inherited by implicit conversion StringFormat from Promise[F, A] to StringFormat[Promise[F, A]]

Inherited by implicit conversion Ensuring from Promise[F, A] to Ensuring[Promise[F, A]]

Inherited by implicit conversion ArrowAssoc from Promise[F, A] to ArrowAssoc[Promise[F, A]]

Ungrouped