Task

object Task
Companion
class
class Object
trait Matchable
class Any

Type members

Classlikes

case
object TaskInterrupted extends InterruptedException

signals task was interrupted *

signals task was interrupted *

Types

type ParallelTask[A] = Task[A] @@ Parallel

type for Tasks which need to be executed in parallel when using an Applicative instance

type for Tasks which need to be executed in parallel when using an Applicative instance

Value members

Concrete methods

def Try[A](a: => A): Throwable \/ A

Utility function - evaluate a and catch and return any exceptions.

Utility function - evaluate a and catch and return any exceptions.

def apply[A](a: => A)(implicit pool: ExecutorService): Task[A]

Create a Task that will evaluate a using the given ExecutorService.

Create a Task that will evaluate a using the given ExecutorService.

def async[A](register: Throwable \/ A => Unit => Unit): Task[A]

Create a Task from an asynchronous computation, which takes the form of a function with which we can register a callback. This can be used to translate from a callback-based API to a straightforward monadic version.

Create a Task from an asynchronous computation, which takes the form of a function with which we can register a callback. This can be used to translate from a callback-based API to a straightforward monadic version.

def delay[A](a: => A): Task[A]

Promote a non-strict value to a Task, catching exceptions in the process. Note that since Task is unmemoized, this will recompute a each time it is sequenced into a larger computation. Memoize a with a lazy value before calling this function if memoization is desired.

Promote a non-strict value to a Task, catching exceptions in the process. Note that since Task is unmemoized, this will recompute a each time it is sequenced into a larger computation. Memoize a with a lazy value before calling this function if memoization is desired.

def fail(e: Throwable): Task[Nothing]

A Task which fails with the given Throwable.

A Task which fails with the given Throwable.

def fork[A](a: => Task[A])(implicit pool: ExecutorService): Task[A]

Returns a Task that produces the same result as the given Future, but forks its evaluation off into a separate (logical) thread, using the given ExecutorService. Note that this forking is only described by the returned Task--nothing occurs until the Task is run.

Returns a Task that produces the same result as the given Future, but forks its evaluation off into a separate (logical) thread, using the given ExecutorService. Note that this forking is only described by the returned Task--nothing occurs until the Task is run.

def fromDisjunction[A <: Throwable, B](x: A \/ B): Task[B]
def fromMaybe[A](ma: Maybe[A])(t: => Throwable): Task[A]
def gatherUnordered[A](tasks: Seq[Task[A]], exceptionCancels: Boolean): Task[List[A]]

Like Nondeterminism[Task].gatherUnordered, but if exceptionCancels is true, exceptions in any task try to immediately cancel all other running tasks. If exceptionCancels is false, in the event of an error, all tasks are run to completion before the error is returned.

Like Nondeterminism[Task].gatherUnordered, but if exceptionCancels is true, exceptions in any task try to immediately cancel all other running tasks. If exceptionCancels is false, in the event of an error, all tasks are run to completion before the error is returned.

Since

7.0.3

def now[A](a: A): Task[A]

Convert a strict value to a Task. Also see delay.

Convert a strict value to a Task. Also see delay.

def point[A](a: => A): Task[A]
def reduceUnordered[A, M](tasks: Seq[Task[A]], exceptionCancels: Boolean)(implicit R: Reducer[A, M]): Task[M]
def schedule[A](a: => A, delay: Duration)(implicit pool: ScheduledExecutorService): Task[A]
def suspend[A](a: => Task[A]): Task[A]

Produce f in the main trampolining loop, Future.step, using a fresh call stack. The standard trampolining primitive, useful for avoiding stack overflows.

Produce f in the main trampolining loop, Future.step, using a fresh call stack. The standard trampolining primitive, useful for avoiding stack overflows.

def tailrecM[A, B](f: A => Task[A \/ B])(a: A): Task[B]
def unsafeStart[A](a: => A)(implicit pool: ExecutorService): Task[A]

Create a Task that starts evaluating a using the given ExecutorService right away. This will start executing side effects immediately, and is thus morally equivalent to unsafePerformIO. The resulting Task cannot be rerun to repeat the effects. Use with care.

Create a Task that starts evaluating a using the given ExecutorService right away. This will start executing side effects immediately, and is thus morally equivalent to unsafePerformIO. The resulting Task cannot be rerun to repeat the effects. Use with care.

Implicits

Implicits

This Applicative instance runs Tasks in parallel.

This Applicative instance runs Tasks in parallel.

It is different from the Applicative instance obtained from Monad[Task] which runs tasks sequentially.