Package jnr.enxio.channels
Class KQSelector
- java.lang.Object
-
- java.nio.channels.Selector
-
- java.nio.channels.spi.AbstractSelector
-
- jnr.enxio.channels.KQSelector
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
class KQSelector extends java.nio.channels.spi.AbstractSelectorAn implementation of aSelectorthat uses the BSD (including MacOS) kqueue(2) mechanism
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classKQSelector.Descriptorprivate static classKQSelector.EventIOprivate static classKQSelector.EventLayoutprivate static classKQSelector.FreeBSD12EventLayoutprivate static classKQSelector.LegacyEventLayout
-
Field Summary
Fields Modifier and Type Field Description private jnr.ffi.Pointerchangebufprivate static booleanDEBUGprivate java.util.Map<java.lang.Integer,KQSelector.Descriptor>descriptorsprivate static intEV_ADDprivate static intEV_CLEARprivate static intEV_DELETEprivate static intEV_DISABLEprivate static intEV_ENABLEprivate jnr.ffi.Pointereventbufprivate static intEVFILT_READprivate static intEVFILT_WRITEprivate KQSelector.EventIOioprivate intkqfdprivate static intMAX_EVENTSprivate int[]pipefdprivate java.lang.ObjectregLockprivate jnr.ffi.Runtimeruntimeprivate java.util.Set<java.nio.channels.SelectionKey>selectedprivate Native.TimespecZERO_TIMESPEC
-
Constructor Summary
Constructors Constructor Description KQSelector(NativeSelectorProvider provider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private inthandleCancelledKeys()private voidhandleChangedKey(KQSelector.Descriptor changed)protected voidimplCloseSelector()(package private) voidinterestOps(KQSelectionKey k, int ops)java.util.Set<java.nio.channels.SelectionKey>keys()private intpoll(long timeout)protected java.nio.channels.SelectionKeyregister(java.nio.channels.spi.AbstractSelectableChannel ch, int ops, java.lang.Object att)intselect()intselect(long timeout)java.util.Set<java.nio.channels.SelectionKey>selectedKeys()intselectNow()java.nio.channels.Selectorwakeup()private voidwakeupReceived()
-
-
-
Field Detail
-
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
-
MAX_EVENTS
private static final int MAX_EVENTS
- See Also:
- Constant Field Values
-
EVFILT_READ
private static final int EVFILT_READ
- See Also:
- Constant Field Values
-
EVFILT_WRITE
private static final int EVFILT_WRITE
- See Also:
- Constant Field Values
-
EV_ADD
private static final int EV_ADD
- See Also:
- Constant Field Values
-
EV_DELETE
private static final int EV_DELETE
- See Also:
- Constant Field Values
-
EV_ENABLE
private static final int EV_ENABLE
- See Also:
- Constant Field Values
-
EV_DISABLE
private static final int EV_DISABLE
- See Also:
- Constant Field Values
-
EV_CLEAR
private static final int EV_CLEAR
- See Also:
- Constant Field Values
-
kqfd
private int kqfd
-
runtime
private final jnr.ffi.Runtime runtime
-
changebuf
private final jnr.ffi.Pointer changebuf
-
eventbuf
private final jnr.ffi.Pointer eventbuf
-
io
private final KQSelector.EventIO io
-
pipefd
private final int[] pipefd
-
regLock
private final java.lang.Object regLock
-
descriptors
private final java.util.Map<java.lang.Integer,KQSelector.Descriptor> descriptors
-
selected
private final java.util.Set<java.nio.channels.SelectionKey> selected
-
ZERO_TIMESPEC
private final Native.Timespec ZERO_TIMESPEC
-
-
Constructor Detail
-
KQSelector
public KQSelector(NativeSelectorProvider provider)
-
-
Method Detail
-
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
-
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)
-
handleCancelledKeys
private int handleCancelledKeys()
-
handleChangedKey
private void handleChangedKey(KQSelector.Descriptor changed)
-
wakeupReceived
private void wakeupReceived()
-
wakeup
public java.nio.channels.Selector wakeup()
- Specified by:
wakeupin classjava.nio.channels.Selector
-
interestOps
void interestOps(KQSelectionKey k, int ops)
-
-