Executor

fun interface Executor(source)

kmp-tor utilizes several different background threads for Jvm & Native which events are generated on, then dispatches them to subscribed observers' OnEvent callbacks. The Executor API allows for fine-tuning the context in which that dispatching occurs on several customizable levels.

Both io.matthewnelson.kmp.tor.runtime.RuntimeEvent and TorEvent observer APIs allow declaration of a specific Executor to be used for the individual observer. If no Executor is specified, then the io.matthewnelson.kmp.tor.runtime.RuntimeEvent.Processor and TorEvent.Processor implementations fallback to using whatever Executor was declared when they were created. This means that an Executor can be set for default behavior of how events get dispatched based off of the needs of the application, and then be selectively overridden on a per-observer basis, when necessary, for the needs of that observer and how it is used and/or implemented.

See also

Inheritors

Types

Link copied to clipboard

Invokes block immediately on whatever thread execute has been called from.

Link copied to clipboard

Utilizes the UI CoroutineDispatcher under the hood to transition events from a background thread, to the UI thread. For Java Compose Desktop, the MainUIDispatcher is used, otherwise Dispatchers.Main (if available).

Functions

Link copied to clipboard
abstract fun execute(handler: CoroutineContext, executable: Executable)

Execute executable in desired context.