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.AbstractSelectorAn implementation of aSelectorthat uses good old poll(2)
-
-
Field Summary
Fields Modifier and Type Field Description private static intEVENTS_OFFSETprivate static intFD_OFFSETprivate PollSelectionKey[]keyArrayprivate java.util.Map<java.nio.channels.SelectionKey,java.lang.Boolean>keysprivate intnfdsprivate int[]pipefdprivate java.nio.ByteBufferpollData(package private) static intPOLLERRprivate static intPOLLFD_SIZE(package private) static intPOLLHUP(package private) static intPOLLIN(package private) static intPOLLOUTprivate java.lang.ObjectregLockprivate static intREVENTS_OFFSETprivate 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 voidadd(PollSelectionKey k)private shortgetPollEvents(int idx)private intgetPollFD(int idx)private shortgetPollRevents(int idx)protected voidimplCloseSelector()(package private) voidinterestOps(PollSelectionKey k, int ops)java.util.Set<java.nio.channels.SelectionKey>keys()private intpoll(long timeout)private voidputPollEvents(int idx, int events)private voidputPollFD(int idx, int fd)private voidputPollRevents(int idx, int events)protected java.nio.channels.SelectionKeyregister(java.nio.channels.spi.AbstractSelectableChannel ch, int ops, java.lang.Object att)private voidremove(PollSelectionKey k)intselect()intselect(long timeout)java.util.Set<java.nio.channels.SelectionKey>selectedKeys()intselectNow()java.nio.channels.Selectorwakeup()private voidwakeupReceived()
-
-
-
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:
implCloseSelectorin 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:
registerin classjava.nio.channels.spi.AbstractSelector
-
keys
public java.util.Set<java.nio.channels.SelectionKey> keys()
- Specified by:
keysin classjava.nio.channels.Selector
-
selectedKeys
public java.util.Set<java.nio.channels.SelectionKey> selectedKeys()
- Specified by:
selectedKeysin 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:
selectNowin classjava.nio.channels.Selector- Throws:
java.io.IOException
-
select
public int select(long timeout) throws java.io.IOException- Specified by:
selectin classjava.nio.channels.Selector- Throws:
java.io.IOException
-
select
public int select() throws java.io.IOException- Specified by:
selectin 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:
wakeupin classjava.nio.channels.Selector
-
-