final class Selector extends IOCloseable
A multiplexor of SelectableChannel
objects.
Please thoroughly read the documentation for the underlying Java API before attempting to use this.
- Alphabetic
- By Inheritance
- Selector
- IOCloseable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Selector(selector: java.nio.channels.Selector)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def close(implicit trace: Trace): IO[IOException, Unit]
Closes this selector.
Closes this selector.
If a thread is currently blocked in one of this selector's selection methods then it is interrupted as if by invoking the selector's wakeup method. Any uncancelled keys still associated with this selector are invalidated, their channels are deregistered, and any other resources associated with this selector are released. If this selector is already closed then invoking this method has no effect. After a selector is closed, any further attempt to use it, except by invoking this method or the wakeup method, will cause a
ClosedSelectorException
to be raised as a defect.- Definition Classes
- Selector → IOCloseable
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def foreachSelectedKey[R, E](f: (SelectionKey) => ZIO[R, E, Boolean])(implicit trace: Trace): ZIO[R, E, Unit]
Performs an effect with each selected key.
Performs an effect with each selected key.
If the result of effect is true, the key will be removed from the selected-key set, which is usually what you want after successfully handling a selected key.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isOpen(implicit trace: Trace): UIO[Boolean]
- def keys(implicit trace: Trace): UIO[Set[SelectionKey]]
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def provider(implicit trace: Trace): UIO[SelectorProvider]
- def removeKey(key: SelectionKey)(implicit trace: Trace): UIO[Unit]
- def select(implicit trace: Trace): IO[IOException, Int]
Performs a blocking select operation.
Performs a blocking select operation.
**Note this will very often block**. This is intended to be used when the effect is locked to an Executor that is appropriate for this. If the fiber is interrupted while blocked in
select
, thenwakeup
is used to unblock it.Dies with
ClosedSelectorException
if this selector is closed.- returns
The number of keys, possibly zero, whose ready-operation sets were updated
- def select(timeout: zio.Duration)(implicit trace: Trace): IO[IOException, Int]
Performs a blocking select operation.
Performs a blocking select operation.
**Note this will very often block**. This is intended to be used when the effect is locked to an Executor that is appropriate for this. If the fiber is interrupted while blocked in
select
, thenwakeup
is used to unblock it.Dies with
ClosedSelectorException
if this selector is closed.- returns
The number of keys, possibly zero, whose ready-operation sets were updated
- def selectNow(implicit trace: Trace): IO[IOException, Int]
Selects a set of keys whose corresponding channels are ready for I/O operations.
Selects a set of keys whose corresponding channels are ready for I/O operations. This method performs a non-blocking selection operation. If no channels have become selectable since the previous selection operation then this method immediately returns zero.
- returns
The number of keys, possibly zero, whose ready-operation sets were updated by the selection operation.
- def selectedKeys(implicit trace: Trace): UIO[Set[SelectionKey]]
Returns this selector's selected-key set.
Returns this selector's selected-key set.
Note that the returned set it mutable - keys may be removed from, but not directly added to it. Any attempt to add an object to the key set will cause an
UnsupportedOperationException
to be thrown. The selected-key set is not thread-safe. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def wakeup(implicit trace: Trace): IO[Nothing, Unit]
Causes the first selection operation that has not yet returned to return immediately.
Causes the first selection operation that has not yet returned to return immediately.
If another thread is currently blocked in an invocation of the
select()
orselect(long)
methods then that invocation will return immediately. If no selection operation is currently in progress then the next invocation of one of these methods will return immediately unless theselectNow()
method is invoked in the meantime. In any case the value returned by that invocation may be non-zero. Subsequent invocations of theselect()
orselect(long)
methods will block as usual unless this method is invoked again in the meantime. Invoking this method more than once between two successive selection operations has the same effect as invoking it just once.