ContextShift

@implicitNotFound("Cannot find an implicit value for ContextShift[${F}]:\n* import ContextShift[${F}] from your effects library\n* if using IO, use cats.effect.IOApp or build one with cats.effect.IO.contextShift\n") trait ContextShift[F[_]]

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
class Object
trait Matchable
class Any

Value members

Abstract methods

def evalOn[A](ec: ExecutionContext)(fa: F[A]): F[A]
Implicitly added by deriveKleisli

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

def evalOn[A](ec: ExecutionContext)(fa: F[A]): F[A]

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

def shift: F[Unit]
Implicitly added by deriveKleisli

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.

def shift: F[Unit]

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

def blockOn[A](blocker: Blocker)(fa: F[A]): F[A]
Implicitly added by deriveKleisli

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

def blockOn[A](blocker: Blocker)(fa: F[A]): F[A]

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