Dispatcher

cats.effect.std.Dispatcher
See theDispatcher companion object
trait Dispatcher[F[_]]

A fiber-based supervisor utility for evaluating effects across an impure boundary. This is useful when working with reactive interfaces that produce potentially many values (as opposed to one), and for each value, some effect in F must be performed (like inserting each value into a queue).

Dispatcher is a kind of Supervisor and accordingly follows the same scoping and lifecycle rules with respect to submitted effects.

Performance note: all clients of a single Dispatcher instance will contend with each other when submitting effects. However, Dispatcher instances are cheap to create and have minimal overhead, so they can be allocated on-demand if necessary.

Notably, Dispatcher replaces Effect and ConcurrentEffect from Cats Effect 2 while only requiring an cats.effect.kernel.Async constraint.

Attributes

Companion
object
Source
Dispatcher.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def unsafeToFutureCancelable[A](fa: F[A]): (Future[A], () => Future[Unit])

Submits an effect to be executed, returning a Future that holds the result of its evaluation, along with a cancelation token that can be used to cancel the original effect.

Submits an effect to be executed, returning a Future that holds the result of its evaluation, along with a cancelation token that can be used to cancel the original effect.

Attributes

Source
Dispatcher.scala

Concrete methods

def unsafeRunAndForget[A](fa: F[A]): Unit

Submits an effect to be executed with fire-and-forget semantics.

Submits an effect to be executed with fire-and-forget semantics.

Attributes

Source
Dispatcher.scala
def unsafeRunCancelable[A](fa: F[A]): () => Future[Unit]

Submits an effect to be executed, returning a cancelation token that can be used to cancel it.

Submits an effect to be executed, returning a cancelation token that can be used to cancel it.

Attributes

Source
Dispatcher.scala
def unsafeToFuture[A](fa: F[A]): Future[A]

Submits an effect to be executed, returning a Future that holds the result of its evaluation.

Submits an effect to be executed, returning a Future that holds the result of its evaluation.

Attributes

Source
Dispatcher.scala

Inherited methods

def unsafeToPromise[A](fa: F[A]): Promise[A]

Submits an effect to be executed, returning a Promise that holds the result of its evaluation.

Submits an effect to be executed, returning a Promise that holds the result of its evaluation.

Attributes

Inherited from:
DispatcherPlatform (hidden)
Source
DispatcherPlatform.scala