Package org.apache.qpid.proton.reactor
Interface Selector
-
public interface Selector
A multiplexor of instances ofSelectable
.Many instances of
Selectable
can be added to a selector, and theselect(long)
method used to block the calling thread until one of theSelectables
becomes read to perform an operation.This class is not thread safe, so only one thread should be manipulating the contents of the selector, or running the
select(long)
method at any given time.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(Selectable selectable)
Adds a selectable to the selector.java.util.Iterator<Selectable>
error()
java.util.Iterator<Selectable>
expired()
void
free()
Frees the resources used by this selector.java.util.Iterator<Selectable>
readable()
void
remove(Selectable selectable)
Removes a selectable from the selector.void
select(long timeout)
Waits for the specified timeout period for one or more selectables to become ready for an operation.void
update(Selectable selectable)
Updates the selector to reflect any changes interest by the specified selectable.java.util.Iterator<Selectable>
writeable()
-
-
-
Method Detail
-
add
void add(Selectable selectable) throws java.io.IOException
Adds a selectable to the selector.- Parameters:
selectable
-- Throws:
java.io.IOException
-
update
void update(Selectable selectable)
Updates the selector to reflect any changes interest by the specified selectable. This is achieved by calling theSelectable.isReading()
andSelectable.isWriting()
methods.- Parameters:
selectable
-
-
remove
void remove(Selectable selectable)
Removes a selectable from the selector.- Parameters:
selectable
-
-
select
void select(long timeout) throws java.io.IOException
Waits for the specified timeout period for one or more selectables to become ready for an operation. Selectables that become ready are returned by thereadable()
,writeable()
,expired()
, orerror()
methods.- Parameters:
timeout
- the maximum number of milliseconds to block the calling thread waiting for a selectable to become ready for an operation. The value zero is interpreted as check but don't block.- Throws:
java.io.IOException
-
readable
java.util.Iterator<Selectable> readable()
- Returns:
- the selectables that have become readable since the last call
to
select(long)
. Callingselect
clears any previous values in this set before adding new values corresponding to those selectables that have become readable.
-
writeable
java.util.Iterator<Selectable> writeable()
- Returns:
- the selectables that have become writable since the last call
to
select(long)
. Callingselect
clears any previous values in this set before adding new values corresponding to those selectables that have become writable.
-
expired
java.util.Iterator<Selectable> expired()
- Returns:
- the selectables that have expired since the last call
to
select(long)
. Callingselect
clears any previous values in this set before adding new values corresponding to those selectables that have now expired.
-
error
java.util.Iterator<Selectable> error()
- Returns:
- the selectables that have encountered an error since the last
call to
select(long)
. Callingselect
clears any previous values in this set before adding new values corresponding to those selectables that have encountered an error.
-
free
void free()
Frees the resources used by this selector.
-
-