Type alias representing callbacks for create tasks.
Groups the implementation for the type-classes defined in monix.types.
Groups the implementation for the type-classes defined in monix.types.
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.
is the callback to execute asynchronously
Create a Task
from an asynchronous computation.
Create a Task
from an asynchronous computation.
Alias for create.
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
Creates a Task
that upon execution will return the result of the
first completed task in the given list and then cancel the rest.
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:
register
callback is async,
forking a (logical) thread
2. execution of the onSuccess
and onError
callbacks,
is async, forking another (logical) threadPoint 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.
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
.
Promote a non-strict value representing a Task to a Task of the same type.
Alias for coeval.
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.
Promote a non-strict value to a Task that is memoized on the first evaluation, the result being then available on subsequent evaluations.
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.
is the task that will get executed asynchronously
is the scheduler to use for execution
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
.
is the task that will get executed asynchronously
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.
Builds a Task instance out of a Scala Try
.
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.
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
.
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.
A Task instance that upon evaluation will never complete.
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.
Returns a Task
that on execution is always successful, emitting
the given strict value.
Lifts a value into the task context.
Lifts a value into the task context. Alias for now.
Returns a task that on execution is always finishing in error emitting the specified exception.
Internal utility - the actual trampoline run-loop implementation.
Internal utility - the actual trampoline run-loop implementation.
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.
Alias for defer.
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.
Type-class instances for Task.
A Task[Unit]
provided for convenience.
Constructs a lazy Task instance whose result will be computed asynchronously.
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
.
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.
Pairs two Task instances.
Pairs three Task instances.
Pairs four Task instances.
Pairs five Task instances.
Pairs six Task instances.
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.
Pairs two Task instances, creating a new instance that will apply the given mapping function to the resulting pair.
Pairs three Task instances, applying the given mapping function to the result.
Pairs four Task instances, applying the given mapping function to the result.
Pairs five Task instances, applying the given mapping function to the result.
Pairs six Task instances, applying the given mapping function to the result.
Alias for coeval.
Alias for coeval. Deprecated.
(Since version 2.0-RC12) Renamed, please use Task.eval
(Since version 2.0-RC12) Renamed to Task.zipMap2
(Since version 2.0-RC12) Renamed to Task.zipMap3
(Since version 2.0-RC12) Renamed to Task.zipMap4
(Since version 2.0-RC12) Renamed to Task.zipMap5
(Since version 2.0-RC12) Renamed to Task.zipMap6