Package jnr.enxio.channels
Class PollSelector
- java.lang.Object
-
- java.nio.channels.Selector
-
- java.nio.channels.spi.AbstractSelector
-
- jnr.enxio.channels.PollSelector
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class PollSelector extends java.nio.channels.spi.AbstractSelector
An implementation of aSelector
that uses good old poll(2)
-
-
Field Summary
Fields Modifier and Type Field Description private static int
EVENTS_OFFSET
private static int
FD_OFFSET
private PollSelectionKey[]
keyArray
private java.util.Map<java.nio.channels.SelectionKey,java.lang.Boolean>
keys
private int
nfds
private int[]
pipefd
private java.nio.ByteBuffer
pollData
(package private) static int
POLLERR
private static int
POLLFD_SIZE
(package private) static int
POLLHUP
(package private) static int
POLLIN
(package private) static int
POLLOUT
private java.lang.Object
regLock
private static int
REVENTS_OFFSET
private java.util.Set<java.nio.channels.SelectionKey>
selected
-
Constructor Summary
Constructors Constructor Description PollSelector(java.nio.channels.spi.SelectorProvider provider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
add(PollSelectionKey k)
private short
getPollEvents(int idx)
private int
getPollFD(int idx)
private short
getPollRevents(int idx)
protected void
implCloseSelector()
(package private) void
interestOps(PollSelectionKey k, int ops)
java.util.Set<java.nio.channels.SelectionKey>
keys()
private int
poll(long timeout)
private void
putPollEvents(int idx, int events)
private void
putPollFD(int idx, int fd)
private void
putPollRevents(int idx, int events)
protected java.nio.channels.SelectionKey
register(java.nio.channels.spi.AbstractSelectableChannel ch, int ops, java.lang.Object att)
private void
remove(PollSelectionKey k)
int
select()
int
select(long timeout)
java.util.Set<java.nio.channels.SelectionKey>
selectedKeys()
int
selectNow()
java.nio.channels.Selector
wakeup()
private void
wakeupReceived()
-
-
-
Field Detail
-
POLLFD_SIZE
private static final int POLLFD_SIZE
- See Also:
- Constant Field Values
-
FD_OFFSET
private static final int FD_OFFSET
- See Also:
- Constant Field Values
-
EVENTS_OFFSET
private static final int EVENTS_OFFSET
- See Also:
- Constant Field Values
-
REVENTS_OFFSET
private static final int REVENTS_OFFSET
- See Also:
- Constant Field Values
-
POLLIN
static final int POLLIN
- See Also:
- Constant Field Values
-
POLLOUT
static final int POLLOUT
- See Also:
- Constant Field Values
-
POLLERR
static final int POLLERR
- See Also:
- Constant Field Values
-
POLLHUP
static final int POLLHUP
- See Also:
- Constant Field Values
-
keyArray
private PollSelectionKey[] keyArray
-
pollData
private java.nio.ByteBuffer pollData
-
nfds
private int nfds
-
pipefd
private final int[] pipefd
-
regLock
private final java.lang.Object regLock
-
keys
private final java.util.Map<java.nio.channels.SelectionKey,java.lang.Boolean> keys
-
selected
private final java.util.Set<java.nio.channels.SelectionKey> selected
-
-
Method Detail
-
putPollFD
private void putPollFD(int idx, int fd)
-
putPollEvents
private void putPollEvents(int idx, int events)
-
getPollFD
private int getPollFD(int idx)
-
getPollEvents
private short getPollEvents(int idx)
-
getPollRevents
private short getPollRevents(int idx)
-
putPollRevents
private void putPollRevents(int idx, int events)
-
implCloseSelector
protected void implCloseSelector() throws java.io.IOException
- Specified by:
implCloseSelector
in classjava.nio.channels.spi.AbstractSelector
- Throws:
java.io.IOException
-
register
protected java.nio.channels.SelectionKey register(java.nio.channels.spi.AbstractSelectableChannel ch, int ops, java.lang.Object att)
- Specified by:
register
in classjava.nio.channels.spi.AbstractSelector
-
keys
public java.util.Set<java.nio.channels.SelectionKey> keys()
- Specified by:
keys
in classjava.nio.channels.Selector
-
selectedKeys
public java.util.Set<java.nio.channels.SelectionKey> selectedKeys()
- Specified by:
selectedKeys
in classjava.nio.channels.Selector
-
interestOps
void interestOps(PollSelectionKey k, int ops)
-
add
private void add(PollSelectionKey k)
-
remove
private void remove(PollSelectionKey k)
-
selectNow
public int selectNow() throws java.io.IOException
- Specified by:
selectNow
in classjava.nio.channels.Selector
- Throws:
java.io.IOException
-
select
public int select(long timeout) throws java.io.IOException
- Specified by:
select
in classjava.nio.channels.Selector
- Throws:
java.io.IOException
-
select
public int select() throws java.io.IOException
- Specified by:
select
in classjava.nio.channels.Selector
- Throws:
java.io.IOException
-
poll
private int poll(long timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
wakeupReceived
private void wakeupReceived() throws java.io.IOException
- Throws:
java.io.IOException
-
wakeup
public java.nio.channels.Selector wakeup()
- Specified by:
wakeup
in classjava.nio.channels.Selector
-
-