public static class AffinityExecutor.DefaultImpls
An extended executor interface that supports thread affinity assertions and short circuiting. This can be useful for ensuring code runs on the right thread, and also for unit testing.
Modifier and Type | Method and Description |
---|---|
static void |
checkOnThread(AffinityExecutor $this)
Throws an IllegalStateException if the current thread is not one of the threads this executor is backed by.
|
static void |
executeASAP(AffinityExecutor $this,
kotlin.jvm.functions.Function0<kotlin.Unit> runnable)
If isOnThread() then runnable is invoked immediately, otherwise the closure is queued onto the backing thread.
|
static <T> T |
fetchFrom(AffinityExecutor $this,
kotlin.jvm.functions.Function0<? extends T> fetcher)
Runs the given function on the executor, blocking until the result is available. Be careful not to deadlock this
way! Make sure the executor can't possibly be waiting for the calling thread.
|
public static void checkOnThread(AffinityExecutor $this)
Throws an IllegalStateException if the current thread is not one of the threads this executor is backed by.
public static void executeASAP(AffinityExecutor $this, kotlin.jvm.functions.Function0<kotlin.Unit> runnable)
If isOnThread() then runnable is invoked immediately, otherwise the closure is queued onto the backing thread.
public static <T> T fetchFrom(AffinityExecutor $this, kotlin.jvm.functions.Function0<? extends T> fetcher)
Runs the given function on the executor, blocking until the result is available. Be careful not to deadlock this way! Make sure the executor can't possibly be waiting for the calling thread.