Task

object Task extends TaskPlatformSpecificFunctions
Authors

杨博 (Yang Bo)

trait TaskPlatformSpecificFunctions
class Object
trait Matchable
class Any

Type members

Types

type TaskDomain = TailRec[Unit] => Throwable

Value members

Concrete methods

inline
def apply[A](inline a: A): () => A
@inline
def delay[A](f: () => A): () => A
@inline
def now[A](a: A): () => A
def onComplete[A](task: () => A)(continue: Try[A] => Unit): Unit
@inline
def switchExecutionContext(executionContext: ExecutionContext): () => Unit

Returns a task that does nothing but let the succeeding tasks run on executionContext

Returns a task that does nothing but let the succeeding tasks run on executionContext

Example

All the code after a !switchExecutionContext should be executed on executionContext

        import com.thoughtworks.dsl.reset, reset._
        import com.thoughtworks.dsl.domains.Task
        import org.scalatest.Assertion
        import scala.concurrent.ExecutionContext
        import com.thoughtworks.dsl.keywords.Shift
        def myTask: Task[Assertion] = Task {
          val originalThread = Thread.currentThread
          !Shift(Task.switchExecutionContext(ExecutionContext.global))
          Thread.currentThread should not be originalThread
        }
        Task.toFuture(myTask)
def toFuture[A](task: () => A): Future[A]

Converts a Task to a scala.concurrent.Future.

Converts a Task to a scala.concurrent.Future.

See also

keywords.Await for converting a scala.concurrent.Future to a Task.