class Task[+A] extends AnyRef

Task[A] wraps a scalaz.concurrent.Future[Throwable \/ A], with some convenience functions for handling exceptions. Its Monad and Nondeterminism instances are derived from Future.

Task (and Future) differ in several key ways from the Future implementation in Scala 2.10 , and have a number of advantages. See the documentation for scalaz.concurrent.Future for more information.

Task is exception-safe when constructed using the primitives in the companion object, but when calling the constructor, you are responsible for ensuring the exception safety of the provided Future.

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

Instance Constructors

  1. new Task(get: Future[\/[Throwable, A]])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def after(t: Duration): Task[A]

    Delays the execution of this Task by the duration t.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def attempt: Task[\/[Throwable, A]]

    'Catches' exceptions in the given task and returns them as values.

  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws(classOf[java.lang.CloneNotSupportedException])
  8. def ensure(failure: ⇒ Throwable)(f: (A) ⇒ Boolean): Task[A]

    Ensures that the result of this Task satisfies the given predicate, or fails with the given value.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  12. def flatMap[B](f: (A) ⇒ Task[B]): Task[B]
  13. val get: Future[\/[Throwable, A]]
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def handle[B >: A](f: PartialFunction[Throwable, B]): Task[B]

    Calls attempt and handles some exceptions using the given partial function, calling Task.now on the result.

    Calls attempt and handles some exceptions using the given partial function, calling Task.now on the result. Any nonmatching exceptions are reraised.

  16. def handleWith[B >: A](f: PartialFunction[Throwable, Task[B]]): Task[B]

    Calls attempt and handles some exceptions using the given partial function.

    Calls attempt and handles some exceptions using the given partial function. Any nonmatching exceptions are reraised.

  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def map[B](f: (A) ⇒ B): Task[B]
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. def onFinish(f: (Option[Throwable]) ⇒ Task[Unit]): Task[A]

    Returns a new Task in which f is scheduled to be run on completion.

    Returns a new Task in which f is scheduled to be run on completion. This would typically be used to release any resources acquired by this Task.

  24. def or[B >: A](t2: Task[B]): Task[B]

    Runs this Task, and if it fails with an exception, runs t2.

    Runs this Task, and if it fails with an exception, runs t2. This is rather coarse-grained. Use attempt, handle, and flatMap for more fine grained control of exception handling.

  25. def retry(delays: Seq[Duration], p: (Throwable) ⇒ Boolean = _.isInstanceOf[Exception]): Task[A]

    Retries this task if it fails, once for each element in delays, each retry delayed by the corresponding duration.

    Retries this task if it fails, once for each element in delays, each retry delayed by the corresponding duration. A retriable failure is one for which the predicate p returns true.

  26. def retryAccumulating(delays: Seq[Duration], p: (Throwable) ⇒ Boolean = _.isInstanceOf[Exception]): Task[(A, List[Throwable])]

    Retries this task if it fails, once for each element in delays, each retry delayed by the corresponding duration, accumulating errors into a list.

    Retries this task if it fails, once for each element in delays, each retry delayed by the corresponding duration, accumulating errors into a list. A retriable failure is one for which the predicate p returns true.

  27. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  28. def timed(timeout: Duration)(implicit scheduler: ScheduledExecutorService = Strategy.DefaultTimeoutScheduler): Task[A]
  29. def timed(timeoutInMillis: Long)(implicit scheduler: ScheduledExecutorService): Task[A]

    A Task which returns a TimeoutException after timeoutInMillis, and attempts to cancel the running computation.

  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. def unsafePerformAsync(f: (\/[Throwable, A]) ⇒ Unit): Unit

    Run this computation to obtain either a result or an exception, then invoke the given callback.

    Run this computation to obtain either a result or an exception, then invoke the given callback. Any pure, non-asynchronous computation at the head of this Task will be forced in the calling thread. At the first Async encountered, control to whatever thread backs the Async and this function returns immediately.

  32. def unsafePerformAsyncInterruptibly(f: (\/[Throwable, A]) ⇒ Unit): () ⇒ Unit

    Similar to unsafePerformAsyncInterruptibly(f,cancel) except instead of interrupting by setting cancel to true, It returns the function, that, when applied will interrupt the task.

    Similar to unsafePerformAsyncInterruptibly(f,cancel) except instead of interrupting by setting cancel to true, It returns the function, that, when applied will interrupt the task.

    This allows "deterministic" completion of task computation even if it was interrupted. That means task will complete even when interrupted, but with TaskInterrupted exception.

    Note 1: When Interrupted, the f callback will run in thread that called the Interrupting function () => Unit Note 2: If task has handler like attempt, it won't get consulted for handling TaskInterrupted excpetion

  33. def unsafePerformAsyncInterruptibly(f: (\/[Throwable, A]) ⇒ Unit, cancel: AtomicBoolean): Unit

    Run this computation to obtain an A, so long as cancel remains false.

    Run this computation to obtain an A, so long as cancel remains false. Because of trampolining, we get frequent opportunities to cancel while stepping through the trampoline, this should provide a fairly robust means of cancellation.

  34. def unsafePerformSync: A

    Run this Task and block until its result is available.

    Run this Task and block until its result is available. This will throw any exceptions generated by the Task. To return exceptions in an \/, use unsafePerformSyncAttempt.

  35. def unsafePerformSyncAttempt: \/[Throwable, A]

    Like unsafePerformSync, but returns exceptions as values.

  36. def unsafePerformSyncAttemptFor(timeout: Duration): \/[Throwable, A]
  37. def unsafePerformSyncAttemptFor(timeoutInMillis: Long): \/[Throwable, A]

    Like unsafePerformSyncFor, but returns exceptions as values.

    Like unsafePerformSyncFor, but returns exceptions as values. Both TimeoutException and other exceptions will be folded into the same Throwable.

  38. def unsafePerformSyncFor(timeout: Duration): A
  39. def unsafePerformSyncFor(timeoutInMillis: Long): A

    Run this Task and block until its result is available, or until timeoutInMillis milliseconds have elapsed, at which point a TimeoutException will be thrown and the Task will attempt to be canceled.

  40. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  41. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def attemptRun: \/[Throwable, A]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformSyncAttempt

  2. def attemptRunFor(timeout: Duration): \/[Throwable, A]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformSyncAttemptFor

  3. def attemptRunFor(timeoutInMillis: Long): \/[Throwable, A]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformSyncAttemptFor

  4. def run: A
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformSync

  5. def runAsync(f: (\/[Throwable, A]) ⇒ Unit): Unit
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformAsync

  6. def runAsyncInterruptibly(f: (\/[Throwable, A]) ⇒ Unit): () ⇒ Unit
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformAsyncInterruptibly

  7. def runAsyncInterruptibly(f: (\/[Throwable, A]) ⇒ Unit, cancel: AtomicBoolean): Unit
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformAsyncInterruptibly

  8. def runFor(timeout: Duration): A
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformSyncFor

  9. def runFor(timeoutInMillis: Long): A
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use unsafePerformSyncFor

  10. def unsafePerformRetry(delays: Seq[Duration], p: (Throwable) ⇒ Boolean = _.isInstanceOf[Exception]): Task[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use retry

  11. def unsafePerformRetryAccumulating(delays: Seq[Duration], p: (Throwable) ⇒ Boolean = _.isInstanceOf[Exception]): Task[(A, List[Throwable])]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use retryAccumulating

  12. def unsafePerformTimed(timeoutInMillis: Long)(implicit scheduler: ScheduledExecutorService): Task[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use timed

  13. def unsafePerformTimed(timeout: Duration)(implicit scheduler: ScheduledExecutorService = Strategy.DefaultTimeoutScheduler): Task[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 7.2) use timed

Inherited from AnyRef

Inherited from Any

Ungrouped