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.
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.
Submits an effect to be executed and indefinitely blocks until a result is produced.
Submits an effect to be executed and indefinitely blocks until a result is produced. This function will throw an exception if the submitted effect terminates with an error.
Submits an effect to be executed and blocks for at most the specified timeout for a result to be produced.
Submits an effect to be executed and blocks for at most the specified timeout for a result to be produced. This function will throw an exception if the submitted effect terminates with an error.