net.corda.node.utilities

## Class AffinityExecutor.DefaultImpls

- net.corda.node.utilities.AffinityExecutor.DefaultImpls

- Enclosing interface:
    AffinityExecutor

      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.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    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.

- - ### Method Detail

    - #### checkOnThread

          public static void checkOnThread(AffinityExecutor $this)

      Throws an IllegalStateException if the current thread is not one of the threads this executor is backed by.

    - #### executeASAP

          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.

    - #### fetchFrom

          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.