corda / net.corda.node.utilities / AffinityExecutor / ServiceAffinityExecutor

# ServiceAffinityExecutor

`open class ServiceAffinityExecutor : AffinityExecutor, ThreadPoolExecutor`

An executor backed by thread pool (which may often have a single thread) which makes it easy to schedule tasks in the future and verify code is running on the executor.

### Constructors

<init> | `ServiceAffinityExecutor(threadName: String, numThreads: Int)` An executor backed by thread pool (which may often have a single thread) which makes it easy to schedule tasks in the future and verify code is running on the executor.

### Properties

isOnThread | `open val isOnThread: Boolean` Returns true if the current thread is equal to the thread this executor is backed by.

### Functions

afterExecute | `open fun afterExecute(r: Runnable, t: Throwable?): Unit`
flush | `open fun flush(): Unit` Run the executor until there are no tasks pending and none executing.

### Inherited Functions

checkOnThread | `open fun checkOnThread(): Unit` Throws an IllegalStateException if the current thread is not one of the threads this executor is backed by.
executeASAP | `open fun executeASAP(runnable: () -> Unit): Unit` If isOnThread() then runnable is invoked immediately, otherwise the closure is queued onto the backing thread.
fetchFrom | `open fun <T> fetchFrom(fetcher: () -> T): T` 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.

### Companion Object Properties

logger | `val logger: Logger`