Object

com.thoughtworks.zerocost

continuation

Related Doc: package zerocost

Permalink

object continuation

The name space that contains continuation.Continuation and utilities for Continuation.

Author:

杨博 (Yang Bo)

Source
continuation.scala
Linear Supertypes
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. continuation
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Continuation[R, +A] = continuation.OpacityTypes.Continuation[R, A]

    Permalink

    The stack-safe and covariant version of Continuations.

    The stack-safe and covariant version of Continuations.

    Note

    The underlying type of this Continuation is (A => TailRec[R]) => TailRec[R].

    See also

    UnitContinuation if you want to use this Continuation as an asynchronous task.

    ContinuationOps for extension methods for this Continuation.

  2. implicit final class ContinuationOps[R, A] extends AnyVal

    Permalink

    Extension methods for Continuation

  3. type ParallelContinuation[A] = Parallel[UnitContinuation, A]

    Permalink

    Parallel-tagged type of UnitContinuation that needs to be executed in parallel when using an cats.Applicative instance

    Parallel-tagged type of UnitContinuation that needs to be executed in parallel when using an cats.Applicative instance

    Examples:
    1. Given two ParallelContinuations, each of them modifies a var,

      import com.thoughtworks.zerocost.parallel._
      import com.thoughtworks.zerocost.continuation._
      var count0 = 0
      var count1 = 0
      val pc0: ParallelContinuation[Unit] = Parallel(Continuation.delay {
        count0 += 1
      })
      val pc1: ParallelContinuation[Unit] = Parallel(Continuation.delay {
        count1 += 1
      })

      when map them together,

      import cats.syntax.all._
      val result: ParallelContinuation[Unit] = (pc0, pc1).mapN{ (u0: Unit, u1: Unit) => }

      then the two vars have not been modified right now,

      count0 should be(0)
      count1 should be(0)

      when the result ParallelContinuation get done, then two vars should be modified only once for each.

      val Parallel(contResult) = result
      contResult.map { _: Unit =>
        count0 should be(1)
        count1 should be(1)
      }.toScalaFuture
    2. ,
    3. Given two ParallelContinuations that contain immediate values,

      import com.thoughtworks.zerocost.parallel._
      import com.thoughtworks.zerocost.continuation._
      val pc0: ParallelContinuation[Int] = Parallel(Continuation.pure[Unit, Int](40))
      val pc1: ParallelContinuation[Int] = Parallel(Continuation.pure[Unit, Int](2))

      when map them together,

      import cats.syntax.all._
      val result: ParallelContinuation[Int] = (pc0, pc1).mapN(_ + _)

      then the result should be a ParallelContinuation as well, and it is able to convert to a normal Continuation

      val Parallel(contResult) = result
      contResult.map {
        _ should be(42)
      }.toScalaFuture
  4. type UnitContinuation[+A] = continuation.OpacityTypes.Continuation[Unit, A]

    Permalink

    A Continuation whose response type is scala.Unit.

    A Continuation whose response type is scala.Unit.

    This UnitContinuation type can be used as an asynchronous task.

    Note

    This UnitContinuation type does not support exception handling.

    See also

    Task for asynchronous task that supports exception handling.

    ParallelContinuation for parallel version of this UnitContinuation.

    UnitContinuationOps for extension methods for this UnitContinuationOps.

  5. implicit final class UnitContinuationOps[A] extends AnyVal

    Permalink

    Extension methods for UnitContinuation

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. object Continuation

    Permalink

    The companion object for Continuation.

  5. object UnitContinuation

    Permalink
  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. implicit def continuationInstances[R]: Monad[[+β$3$]continuation.OpacityTypes.Continuation[R, β$3$]] with LiftIO[[+β$4$]continuation.OpacityTypes.Continuation[R, β$4$]]

    Permalink

    Note

    When creating two no-op Continuations from continuationInstances.unit,

    import com.thoughtworks.zerocost.continuation._
    import cats.Applicative
    val noop0 = Applicative[UnitContinuation].unit
    val noop1 = Applicative[UnitContinuation].unit

    then the two no-op should equal to each other.

    noop0 should be(noop1)
  9. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

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

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

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

    Permalink
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  18. implicit val parallelContinuationInstances: Monad[ParallelContinuation] with LiftIO[ParallelContinuation]

    Permalink

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Implicit Views

Type class instances

Ungrouped