ResumableJob

A resumable job can be started in one worker and can be resumed in the original caller worker. For example, an API call can be started in a background worker but its results can be delivered on the main thread. The resumed job is a closure which takes the output of the original job as input. The caller does not need to wait for the background worker to complete just like co-routines as the resuming job is added to the event loop of the caller thread.

Note: This is an attempt to close the gap until multi-threaded coroutines become available on both platforms.

class ResumableJob<JobInput, ResultHandlerInput, ResultHandlerOutput>

Parameters

JobInput

the type of job input

ResultHandlerInput

the type of job out put which will be passed to the result handler

ResultHandlerOutput

the type of the

Types

Companion
Link copied to clipboard
common
object Companion

Functions

equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
toString
Link copied to clipboard
common
open override fun toString(): String

Properties

awaitResumingJob
Link copied to clipboard
common

whether target worker should wait for the resumed job closure to complete. It is useful in testing.

val awaitResumingJob: Boolean
job
Link copied to clipboard
common

the non capturing closure which will execute on the target worker.

val job: (JobInput) -> ResultHandlerInput
jobInput
Link copied to clipboard
common

the input to the job which will execute on the target worker.

val jobInput: JobInput
resumingJob
Link copied to clipboard
common

the non capturing closure which runs on the caller thread and accepts the job output as the only argument.

val resumingJob: (ResultHandlerInput) -> ResultHandlerOutput
resumingWorker
Link copied to clipboard
common

the worker on which the job should be resumed once the target worker is finished.

val resumingWorker: Worker