Object/Class

monix.eval

Task

Related Docs: class Task | package eval

Permalink

object Task extends TaskInstances with Serializable

Source
Task.scala
Linear Supertypes
Serializable, Serializable, TaskInstances, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Task
  2. Serializable
  3. Serializable
  4. TaskInstances
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type OnFinish[+A] = (Scheduler, StackedCancelable, Callback[A]) ⇒ Unit

    Permalink

    Type alias representing callbacks for create tasks.

  2. class TypeClassInstances extends DeferrableClass[Task] with MemoizableClass[Task] with RecoverableClass[Task, Throwable] with CoflatMapClass[Task] with MonadRecClass[Task]

    Permalink

    Groups the implementation for the type-classes defined in monix.types.

    Groups the implementation for the type-classes defined in monix.types.

    Definition Classes
    TaskInstances

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 apply[A](f: ⇒ A): Task[A]

    Permalink

    Returns a new task that, when executed, will emit the result of the given function, executed asynchronously.

    Returns a new task that, when executed, will emit the result of the given function, executed asynchronously.

    f

    is the callback to execute asynchronously

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def async[A](register: (Scheduler, Callback[A]) ⇒ Cancelable): Task[A]

    Permalink

    Create a Task from an asynchronous computation.

    Create a Task from an asynchronous computation.

    Alias for create.

  7. def chooseFirstOf[A, B](fa: Task[A], fb: Task[B]): Task[Either[(A, CancelableFuture[B]), (CancelableFuture[A], B)]]

    Permalink

    Creates a Task that upon execution will execute both given tasks (possibly in parallel in case the tasks are asynchronous) and will return the result of the task that manages to complete first, along with a cancelable future of the other task.

    Creates a Task that upon execution will execute both given tasks (possibly in parallel in case the tasks are asynchronous) and will return the result of the task that manages to complete first, along with a cancelable future of the other task.

    If the first task that completes

  8. def chooseFirstOfList[A](tasks: TraversableOnce[Task[A]]): Task[A]

    Permalink

    Creates a Task that upon execution will return the result of the first completed task in the given list and then cancel the rest.

  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def coeval[A](a: Coeval[A]): Task[A]

    Permalink

    Transforms a Coeval into a Task.

  11. def create[A](register: (Scheduler, Callback[A]) ⇒ Cancelable): Task[A]

    Permalink

    Create a Task from an asynchronous computation, which takes the form of a function with which we can register a callback.

    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.

    Contract:

    1. execution of the register callback is async, forking a (logical) thread 2. execution of the onSuccess and onError callbacks, is async, forking another (logical) thread

    Point number 2 happens because create is supposed to be safe or otherwise, depending on the executed logic, one can end up with a stack overflow exception. So this contract happens in order to guarantee safety. In order to bypass rule number 2, one can use unsafeCreate, but that's for people knowing what they are doing.

    register

    is a function that will be called when this Task is executed, receiving a callback as a parameter, a callback that the user is supposed to call in order to signal the desired outcome of this Task.

  12. def defer[A](fa: ⇒ Task[A]): Task[A]

    Permalink

    Promote a non-strict value representing a Task to a Task of the same type.

  13. def delay[A](a: ⇒ A): Task[A]

    Permalink

    Alias for coeval.

  14. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  16. def eval[A](a: ⇒ A): Task[A]

    Permalink

    Promote a non-strict value to a Task, catching exceptions in the process.

    Promote a non-strict value to a Task, catching exceptions in the process.

    Note that since Task is not memoized, this will recompute the value each time the Task is executed.

  17. def evalOnce[A](a: ⇒ A): Task[A]

    Permalink

    Promote a non-strict value to a Task that is memoized on the first evaluation, the result being then available on subsequent evaluations.

  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def fork[A](fa: Task[A], scheduler: Scheduler): Task[A]

    Permalink

    Mirrors the given source Task, but upon execution ensure that evaluation forks into a separate (logical) thread.

    Mirrors the given source Task, but upon execution ensure that evaluation forks into a separate (logical) thread.

    The given Scheduler will be used for execution of the Task, effectively overriding the Scheduler that's passed in runAsync. Thus you can execute a whole Task on a separate thread-pool, useful for example in case of doing I/O.

    fa

    is the task that will get executed asynchronously

    scheduler

    is the scheduler to use for execution

  20. def fork[A](fa: Task[A]): Task[A]

    Permalink

    Mirrors the given source Task, but upon execution ensure that evaluation forks into a separate (logical) thread.

    Mirrors the given source Task, but upon execution ensure that evaluation forks into a separate (logical) thread.

    The Scheduler used will be the one that is used to start the run-loop in runAsync.

    fa

    is the task that will get executed asynchronously

  21. def fromFuture[A](f: Future[A]): Task[A]

    Permalink

    Converts the given Scala Future into a Task.

    Converts the given Scala Future into a Task.

    NOTE: if you want to defer the creation of the future, use in combination with defer.

  22. def fromTry[A](a: Try[A]): Task[A]

    Permalink

    Builds a Task instance out of a Scala Try.

  23. def gather[A, M[X] <: TraversableOnce[X]](in: M[Task[A]])(implicit cbf: CanBuildFrom[M[Task[A]], A, M[A]]): Task[M[A]]

    Permalink

    Nondeterministically gather results from the given collection of tasks, returning a task that will signal the same type of collection of results once all tasks are finished.

    Nondeterministically gather results from the given collection of tasks, returning a task that will signal the same type of collection of results once all tasks are finished.

    This function is the nondeterministic analogue of sequence and should behave identically to sequence so long as there is no interaction between the effects being gathered. However, unlike sequence, which decides on a total order of effects, the effects in a gather are unordered with respect to each other.

    Although the effects are unordered, we ensure the order of results matches the order of the input sequence. Also see gatherUnordered for the more efficient alternative.

  24. def gatherUnordered[A, M[X] <: TraversableOnce[X]](in: M[Task[A]])(implicit cbf: CanBuildFrom[M[Task[A]], A, M[A]]): Task[M[A]]

    Permalink

    Nondeterministically gather results from the given collection of tasks, without keeping the original ordering of results.

    Nondeterministically gather results from the given collection of tasks, without keeping the original ordering of results.

    This function is similar to gather, but neither the effects nor the results will be ordered. Useful when you don't need ordering because it can be more efficient than gather.

  25. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  28. def mapBoth[A1, A2, R](fa1: Task[A1], fa2: Task[A2])(f: (A1, A2) ⇒ R): Task[R]

    Permalink

    Apply a mapping functions to the results of two tasks, nondeterministically ordering their effects.

    Apply a mapping functions to the results of two tasks, nondeterministically ordering their effects.

    If the two tasks are synchronous, they'll get executed one after the other, with the result being available asynchronously. If the two tasks are asynchronous, they'll get scheduled for execution at the same time and in a multi-threading environment they'll execute in parallel and have their results synchronized.

  29. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. def never[A]: Task[A]

    Permalink

    A Task instance that upon evaluation will never complete.

  31. implicit val nondeterminism: TypeClassInstances

    Permalink

    Type-class instances for Task that have nondeterministic effects for Applicative.

    Type-class instances for Task that have nondeterministic effects for Applicative.

    It can be optionally imported in scope to make map2 and ap to potentially run tasks in parallel.

    Definition Classes
    TaskInstances
  32. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  34. def now[A](a: A): Task[A]

    Permalink

    Returns a Task that on execution is always successful, emitting the given strict value.

  35. def pure[A](a: A): Task[A]

    Permalink

    Lifts a value into the task context.

    Lifts a value into the task context. Alias for now.

  36. def raiseError[A](ex: Throwable): Task[A]

    Permalink

    Returns a task that on execution is always finishing in error emitting the specified exception.

  37. def runLoop(scheduler: Scheduler, em: ExecutionModel, conn: StackedCancelable, source: Current, cb: Callback[Any], binds: List[Bind], frameIndex: Int): Unit

    Permalink

    Internal utility - the actual trampoline run-loop implementation.

    Internal utility - the actual trampoline run-loop implementation.

    Annotations
    @tailrec()
  38. def sequence[A, M[X] <: TraversableOnce[X]](in: M[Task[A]])(implicit cbf: CanBuildFrom[M[Task[A]], A, M[A]]): Task[M[A]]

    Permalink

    Given a TraversableOnce of tasks, transforms it to a task signaling the collection, executing the tasks one by one and gathering their results in the same collection.

    Given a TraversableOnce of tasks, transforms it to a task signaling the collection, executing the tasks one by one and gathering their results in the same collection.

    This operation will execute the tasks one by one, in order, which means that both effects and results will be ordered. See gather and gatherUnordered for unordered results or effects, and thus potential of running in parallel.

    It's a simple version of traverse.

  39. def suspend[A](fa: ⇒ Task[A]): Task[A]

    Permalink

    Alias for defer.

  40. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    AnyRef → Any
  42. def traverse[A, B, M[X] <: TraversableOnce[X]](in: M[A])(f: (A) ⇒ Task[B])(implicit cbf: CanBuildFrom[M[A], B, M[B]]): Task[M[B]]

    Permalink

    Given a TraversableOnce[A] and a function A => Task[B], sequentially apply the function to each element of the collection and gather their results in the same collection.

    Given a TraversableOnce[A] and a function A => Task[B], sequentially apply the function to each element of the collection and gather their results in the same collection.

    It's a generalized version of sequence.

  43. implicit val typeClassInstances: TypeClassInstances

    Permalink

    Type-class instances for Task.

  44. final val unit: Task[Unit]

    Permalink

    A Task[Unit] provided for convenience.

  45. def unsafeCreate[A](onFinish: OnFinish[A]): Task[A]

    Permalink

    Constructs a lazy Task instance whose result will be computed asynchronously.

    Constructs a lazy Task instance whose result will be computed asynchronously.

    Unsafe to use directly, only use if you know what you're doing. For building Task instances safely see create.

  46. def unsafeStartAsync[A](source: Task[A], scheduler: Scheduler, conn: StackedCancelable, cb: Callback[A]): Unit

    Permalink

    Unsafe utility - starts the execution of a Task with a guaranteed asynchronous boundary, by providing the needed Scheduler, StackedCancelable and Callback.

    Unsafe utility - starts the execution of a Task with a guaranteed asynchronous boundary, by providing the needed Scheduler, StackedCancelable and Callback.

    DO NOT use directly, as it is UNSAFE to use, unless you know what you're doing. Prefer Task.runAsync and Task.fork.

  47. def unsafeStartNow[A](source: Task[A], scheduler: Scheduler, conn: StackedCancelable, cb: Callback[A]): Unit

    Permalink

    Unsafe utility - starts the execution of a Task, by providing the needed Scheduler, StackedCancelable and Callback.

    Unsafe utility - starts the execution of a Task, by providing the needed Scheduler, StackedCancelable and Callback.

    DO NOT use directly, as it is UNSAFE to use, unless you know what you're doing. Prefer Task.runAsync.

  48. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. def zip2[A1, A2, R](fa1: Task[A1], fa2: Task[A2]): Task[(A1, A2)]

    Permalink

    Pairs two Task instances.

  52. def zip3[A1, A2, A3](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3]): Task[(A1, A2, A3)]

    Permalink

    Pairs three Task instances.

  53. def zip4[A1, A2, A3, A4](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4]): Task[(A1, A2, A3, A4)]

    Permalink

    Pairs four Task instances.

  54. def zip5[A1, A2, A3, A4, A5](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4], fa5: Task[A5]): Task[(A1, A2, A3, A4, A5)]

    Permalink

    Pairs five Task instances.

  55. def zip6[A1, A2, A3, A4, A5, A6](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4], fa5: Task[A5], fa6: Task[A6]): Task[(A1, A2, A3, A4, A5, A6)]

    Permalink

    Pairs six Task instances.

  56. def zipList[A](sources: Task[A]*): Task[List[A]]

    Permalink

    Gathers the results from a sequence of tasks into a single list.

    Gathers the results from a sequence of tasks into a single list. The effects are not ordered, but the results are.

  57. def zipMap2[A1, A2, R](fa1: Task[A1], fa2: Task[A2])(f: (A1, A2) ⇒ R): Task[R]

    Permalink

    Pairs two Task instances, creating a new instance that will apply the given mapping function to the resulting pair.

  58. def zipMap3[A1, A2, A3, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3])(f: (A1, A2, A3) ⇒ R): Task[R]

    Permalink

    Pairs three Task instances, applying the given mapping function to the result.

  59. def zipMap4[A1, A2, A3, A4, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4])(f: (A1, A2, A3, A4) ⇒ R): Task[R]

    Permalink

    Pairs four Task instances, applying the given mapping function to the result.

  60. def zipMap5[A1, A2, A3, A4, A5, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4], fa5: Task[A5])(f: (A1, A2, A3, A4, A5) ⇒ R): Task[R]

    Permalink

    Pairs five Task instances, applying the given mapping function to the result.

  61. def zipMap6[A1, A2, A3, A4, A5, A6, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4], fa5: Task[A5], fa6: Task[A6])(f: (A1, A2, A3, A4, A5, A6) ⇒ R): Task[R]

    Permalink

    Pairs six Task instances, applying the given mapping function to the result.

Deprecated Value Members

  1. def evalAlways[A](a: ⇒ A): Task[A]

    Permalink

    Alias for coeval.

    Alias for coeval. Deprecated.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.0-RC12) Renamed, please use Task.eval

  2. def zipWith2[A1, A2, R](fa1: Task[A1], fa2: Task[A2])(f: (A1, A2) ⇒ R): Task[R]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0-RC12) Renamed to Task.zipMap2

  3. def zipWith3[A1, A2, A3, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3])(f: (A1, A2, A3) ⇒ R): Task[R]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0-RC12) Renamed to Task.zipMap3

  4. def zipWith4[A1, A2, A3, A4, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4])(f: (A1, A2, A3, A4) ⇒ R): Task[R]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0-RC12) Renamed to Task.zipMap4

  5. def zipWith5[A1, A2, A3, A4, A5, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4], fa5: Task[A5])(f: (A1, A2, A3, A4, A5) ⇒ R): Task[R]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0-RC12) Renamed to Task.zipMap5

  6. def zipWith6[A1, A2, A3, A4, A5, A6, R](fa1: Task[A1], fa2: Task[A2], fa3: Task[A3], fa4: Task[A4], fa5: Task[A5], fa6: Task[A6])(f: (A1, A2, A3, A4, A5, A6) ⇒ R): Task[R]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0-RC12) Renamed to Task.zipMap6

Inherited from Serializable

Inherited from Serializable

Inherited from TaskInstances

Inherited from AnyRef

Inherited from Any

Ungrouped