SelectorLoop

final class SelectorLoop(selector: Selector, bufferSize: Int, threadFactory: ThreadFactory) extends Executor with ExecutionContext

A special thread that listens for events on the provided selector.

Value Params
bufferSize

Size of the scratch buffer instantiated for this thread.

selector

Selector to listen on.

threadFactory

Factory to make the Thread instance to run the loop.

Note

when the SelectorLoop is closed all registered Selectables are closed with it.

trait ExecutionContext
trait Executor
class Object
trait Matchable
class Any

Type members

Classlikes

abstract class LoopRunnable extends Runnable

A Runnable that will only execute in this selector loop and provides access to the SelectorLoops scratch buffer.

A Runnable that will only execute in this selector loop and provides access to the SelectorLoops scratch buffer.

Value members

Concrete methods

def close(): Unit

Signal to the SelectorLoop that it should close

Signal to the SelectorLoop that it should close

@throws(scala.throws.$lessinit$greater$default$1[java.util.concurrent.RejectedExecutionException])
def enqueueTask(runnable: Runnable): Unit

Schedule to provided Runnable for execution later

Schedule to provided Runnable for execution later

The task will be added to the end of the queue of tasks scheduled for execution regardless of where this method is called.

See also

executeTask for a method that will execute the task now if the calling thread is this SelectorLoop, or schedule it for later otherwise.

@throws(scala.throws.$lessinit$greater$default$1[java.util.concurrent.RejectedExecutionException])
override def execute(runnable: Runnable): Unit
Definition Classes
ExecutionContext -> Executor
@inline @throws(scala.throws.$lessinit$greater$default$1[java.util.concurrent.RejectedExecutionException])
def executeTask(runnable: Runnable): Unit

Schedule the provided Runnable for execution, potentially running it now

Schedule the provided Runnable for execution, potentially running it now

The provided task may be executed now if the calling thread is this SelectorLoop, otherwise it is added to the task queue to be executed by the SelectorLoop thread later.

def initChannel(ch: NIO1Channel, mkStage: SelectionKey => Selectable): Unit

Initialize a new Selectable channel

Initialize a new Selectable channel

The SelectableChannel is added to the selector loop the Selectable will be notified when it has events ready.

Note

the underlying SelectableChannel must be configured in non-blocking mode.

override def reportFailure(cause: Throwable): Unit
Definition Classes
ExecutionContext

Deprecated and Inherited methods

@deprecated(message = "preparation of ExecutionContexts will be removed", since = "2.12.0")
def prepare(): ExecutionContext
Deprecated
[Since version 2.12.0] preparation of ExecutionContexts will be removed
Inherited from
ExecutionContext