Type/Object

com.thoughtworks.dsl.domains.task

Task

Related Docs: object Task | package task

Permalink

type Task[+A] = ((A) ⇒ com.thoughtworks.dsl.domains.task.TaskDomain @com.thoughtworks.dsl.Dsl.reset) ⇒ TaskDomain

The asynchronous task that supports exception handling, resource management, and is stack-safe.

Source
task.scala
Example:
  1. A Task can be created from for-comprehension, where keywords.Each and keywords.Fork can be used together to asynchronously iterate collections. For example, the above concatenateRemoteData downloads and concatenates data from multiple URLs.

    import com.thoughtworks.dsl.comprehension._
    import com.thoughtworks.dsl.keywords._
    import com.thoughtworks.dsl.keywords.Shift._
    import com.thoughtworks.dsl.domains.task.Task
    import java.net.URL
    def concatenateRemoteData(urls: List[URL], downloader: URL => Task[Vector[Byte]]): Task[Vector[Byte]] = {
      for {
        url <- Fork(urls)
        data <- downloader(url)
        byte <- Each(data)
      } yield byte
    }.as[Task[Vector[Byte]]]

    A Task can be also created from Task.apply

    def mockDownloader(url: URL) = Task {
      "mock data\n".getBytes.toVector
    }

    A Task can be then converted to scala.concurrent.Future via Task.toFuture, in order to integrate into other frameworks. In this example, it's a Future[Assertion] required by org.scalatest.AsyncFreeSpec.

    val mockUrls = List(new URL("http://example.com/file1"), new URL("http://example.com/file2"))
    import org.scalatest.Assertion
    def assertion: Task[Assertion] = Task {
      !concatenateRemoteData(mockUrls, mockDownloader) should be("mock data\nmock data\n".getBytes.toVector)
    }
    Task.toFuture(assertion)
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Task
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def apply(v1: T1): R

    Permalink
    Definition Classes
    Function1

Concrete 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. def andThen[A](g: (R) ⇒ A): (T1) ⇒ A

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def compose[A](g: (A) ⇒ T1): (A) ⇒ R

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  8. final def eq(arg0: AnyRef): Boolean

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  17. final def synchronized[T0](arg0: ⇒ T0): T0

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

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

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped