TreehouseDispatchers

@ObjCName(name = "TreehouseDispatchers", exact = true)
interface TreehouseDispatchers : AutoCloseable

One of the trickiest things Treehouse needs to do is balance its two dispatchers:

  • ui executes dispatched tasks on the platform's UI thread.

  • zipline executes dispatched tasks on the thread where downloaded code executes.

This class makes it easier to specify invariants on which dispatcher is expected for which work.

Each TreehouseApp gets its own instance of this class and has its own private Zipline thread. All apps share the same UI thread.

Properties

Link copied to clipboard
abstract val ui: CoroutineDispatcher
Link copied to clipboard
abstract val zipline: CoroutineDispatcher

Functions

Link copied to clipboard
abstract fun checkUi()

Confirm that this is being called on the UI thread.

Link copied to clipboard
abstract fun checkZipline()

Confirm that this is being called on the zipline thread.

Link copied to clipboard
abstract override fun close()

Release the threads owned by this instance. On most platforms this will not release the UI thread as it is not owned by this instance.