ContextShift provides support for shifting execution.
The shift
method inserts an asynchronous boundary, which moves execution
from the calling thread to the default execution environment of F
.
The evalOn
method provides a way to evaluate a task on a specific execution
context, shifting back to the default execution context after the task completes.
This is NOT a type class, as it does not have the coherence requirement.
- Companion
- object
Value members
Abstract methods
Evaluates fa
on the supplied execution context and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
Evaluates fa
on the supplied execution context and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
The primary use case for this method is executing code on a
specific execution context. To execute blocking code, consider using
the blockOn(blocker)
method instead.
- Value Params
- ec
Execution context where the evaluation has to be scheduled
- fa
Computation to evaluate using
ec
Evaluates fa
on the supplied execution context and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
Evaluates fa
on the supplied execution context and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
The primary use case for this method is executing code on a
specific execution context. To execute blocking code, consider using
the blockOn(blocker)
method instead.
- Value Params
- ec
Execution context where the evaluation has to be scheduled
- fa
Computation to evaluate using
ec
Asynchronous boundary described as an effectful F[_]
that
can be used in flatMap
chains to "shift" the continuation
of the run-loop to another thread or call stack.
Asynchronous boundary described as an effectful F[_]
that
can be used in flatMap
chains to "shift" the continuation
of the run-loop to another thread or call stack.
This is the Async.shift operation, without the need for an
ExecutionContext
taken as a parameter.
Asynchronous boundary described as an effectful F[_]
that
can be used in flatMap
chains to "shift" the continuation
of the run-loop to another thread or call stack.
Asynchronous boundary described as an effectful F[_]
that
can be used in flatMap
chains to "shift" the continuation
of the run-loop to another thread or call stack.
This is the Async.shift operation, without the need for an
ExecutionContext
taken as a parameter.
Concrete methods
Evaluates fa
on the supplied blocker and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
Evaluates fa
on the supplied blocker and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
The primary use case for this method is executing blocking code on a dedicated execution context.
- Value Params
- blocker
blocker where the evaluation has to be scheduled
- fa
Computation to evaluate using
blocker
Evaluates fa
on the supplied blocker and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
Evaluates fa
on the supplied blocker and shifts evaluation
back to the default execution environment of F
at the completion of fa
,
regardless of success or failure.
The primary use case for this method is executing blocking code on a dedicated execution context.
- Value Params
- blocker
blocker where the evaluation has to be scheduled
- fa
Computation to evaluate using
blocker