object Dispatcher
- Source
- Dispatcher.scala
- Alphabetic
- By Inheritance
- Dispatcher
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def parallel[F[_]](await: Boolean)(implicit arg0: kernel.Async[F]): kernel.Resource[F, Dispatcher[F]]
Create a Dispatcher that can be used within a resource scope.
Create a Dispatcher that can be used within a resource scope. Once the resource scope exits, depending on the termination policy all active effects will be canceled or awaited, and attempts to submit new effects will throw an exception.
This corresponds to a pattern in which a single
Dispatcher
is being used by multiple calling threads simultaneously, with complex (potentially long-running) actions submitted for evaluation. In this mode, order of operation is not in any way guaranteed, and execution of each submitted action has some unavoidable overhead due to the forking of a new fiber for each action. This mode is most appropriate for scenarios in which a singleDispatcher
is being widely shared across the application, and where sequencing is not assumed.The lifecycle of spawned fibers is managed by Supervisor. The termination policy can be configured by the
await
parameter.- await
the termination policy of the internal Supervisor.
- true - wait for the completion of the active fibers
- false - cancel the active fibers
- Note
if an effect that never completes, is evaluating by a
Dispatcher
with awaiting termination policy, the termination of theDispatcher
is indefinitely suspendedval io: IO[Unit] = // never completes Dispatcher.parallel[F](await = true).use { dispatcher => dispatcher.unsafeRunAndForget(Concurrent[F].never) Concurrent[F].unit }
- See also
Supervisor for the termination policy details
- def parallel[F[_]](implicit arg0: kernel.Async[F]): kernel.Resource[F, Dispatcher[F]]
Create a Dispatcher that can be used within a resource scope.
Create a Dispatcher that can be used within a resource scope. Once the resource scope exits, all active effects will be canceled, and attempts to submit new effects will throw an exception.
- def sequential[F[_]](await: Boolean)(implicit arg0: kernel.Async[F]): kernel.Resource[F, Dispatcher[F]]
Create a Dispatcher that can be used within a resource scope.
Create a Dispatcher that can be used within a resource scope. Once the resource scope exits, depending on the termination policy all active effects will be canceled or awaited, and attempts to submit new effects will throw an exception.
This corresponds to a Dispatcher mode in which submitted actions are evaluated strictly in sequence (FIFO). In this mode, any actions submitted to Dispatcher.unsafeRunAndForget are guaranteed to run in exactly the order submitted, and subsequent actions will not start evaluation until previous actions are completed. This avoids a significant amount of overhead associated with the Parallel mode and allows callers to make assumptions around ordering, but the downside is that long-running actions will starve subsequent actions, and all submitters must contend for a singular coordination resource. Thus, this mode is most appropriate for cases where the actions are relatively trivial (such as Queue.offer) and the
Dispatcher
in question is not shared across multiple producers. To be clear, shared dispatchers in sequential mode will still function correctly, but performance will be suboptimal due to single-point contention.- await
the termination policy.
- true - wait for the completion of the active fiber
- false - cancel the active fiber
- Note
if an effect that never completes, is evaluating by a
Dispatcher
with awaiting termination policy, the termination of theDispatcher
is indefinitely suspendedval io: IO[Unit] = // never completes Dispatcher.sequential[IO](await = true).use { dispatcher => dispatcher.unsafeRunAndForget(IO.never) IO.unit }
- def sequential[F[_]](implicit arg0: kernel.Async[F]): kernel.Resource[F, Dispatcher[F]]
Create a Dispatcher that can be used within a resource scope.
Create a Dispatcher that can be used within a resource scope. Once the resource scope exits, all active effects will be canceled, and attempts to submit new effects will throw an exception.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def apply[F[_]](implicit arg0: kernel.Async[F]): kernel.Resource[F, Dispatcher[F]]
- Annotations
- @deprecated
- Deprecated
(Since version 3.4.0) use '.parallel' or '.sequential' instead; the former corresponds to the current semantics of '.apply'