SelectorManagerSupport

abstract class SelectorManagerSupport : SelectorManager

Base class for NIO selector managers

Exceptions

ClosedSelectorCancellationException

class ClosedSelectorCancellationException : 
    CancellationException

Properties

cancelled

var cancelled: Int

Number of cancelled keys

pending

var pending: Int

Number of pending selectables

provider

val provider: SelectorProvider

NIO selector provider

Functions

applyInterest

fun applyInterest(selector: Selector, s: Selectable): Unit

Applies selectable’s current interest (should be invoked in selection thread)

cancelAllSuspensions

fun cancelAllSuspensions(
    attachment: Selectable,
    t: Throwable
): Unit

Cancel all selectable’s suspensions with the specified exception

fun cancelAllSuspensions(
    selector: Selector,
    t: Throwable?
): Unit

Cancel all suspensions with the specified exception, reset all interests

handleSelectedKey

fun handleSelectedKey(key: SelectionKey): Unit

Handles particular selected key

handleSelectedKeys

fun handleSelectedKeys(
    selectedKeys: MutableSet<SelectionKey>,
    keys: Set<SelectionKey>
): Unit

Handle selected keys clearing selectedKeys set

notifyClosedImpl

fun notifyClosedImpl(
    selector: Selector,
    key: SelectionKey,
    attachment: Selectable
): Unit

Notify selectable’s closure

publishInterest

abstract fun publishInterest(selectable: Selectable): Unit

Publish current selectable interest, any thread

select

suspend fun select(
    selectable: Selectable,
    interest: SelectInterest
): Unit

Suspends until interest is selected for selectable May cause manager to allocate and run selector instance if not yet created.

Inherited Functions

notifyClosed

abstract fun notifyClosed(s: Selectable): Unit

Notifies the selector that selectable has been closed.

Extension Functions

buildOrClose

fun <C : Closeable, R> SelectorManager.buildOrClose(
    create: SelectorProvider.() -> C,
    setup: C.() -> R
): R

Creates a NIO entity via create and calls setup on it. If any exception happens then the entity will be closed and an exception will be propagated.

Inheritors

ActorSelectorManager

class ActorSelectorManager : 
    SelectorManagerSupport,
    Closeable,
    CoroutineScope

Default CIO selector manager implementation