Task

com.thoughtworks.dsl.domains.Task$package$.Task$
object Task

Attributes

Authors:

杨博 (Yang Bo)

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Task.type

Members list

Concise view

Type members

Value members

Concrete methods

inline def apply[A](inline a: A): () => A
def delay[A](f: () => A): () => A
def now[A](a: A): () => A
def onComplete[A](task: () => A)(continue: Try[A] => Unit): Unit
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

Attributes

Example:

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

         import com.thoughtworks.dsl.macros.Reset.Default.*
         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.

Attributes

See also:

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