Object

com.thoughtworks.dsl.domains

task

Related Doc: package domains

Permalink

object task

Author:

杨博 (Yang Bo)

Source
task.scala
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

Type Members

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

    Permalink

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

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

    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.freespec.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)
  2. type TaskDomain = ((Throwable) ⇒ util.control.TailCalls.TailRec[Unit] @com.thoughtworks.dsl.Dsl.reset) ⇒ TailRec[Unit]

    Permalink

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 Task

    Permalink
  5. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  15. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(arg0: Long, arg1: Int): Unit

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(): Unit

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

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Ungrouped