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.AbstractSelector
An implementation of aSelector
that uses the BSD (including MacOS) kqueue(2) mechanism
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
KQSelector.Descriptor
private static class
KQSelector.EventIO
private static class
KQSelector.EventLayout
private static class
KQSelector.FreeBSD12EventLayout
private static class
KQSelector.LegacyEventLayout
-
Field Summary
Fields Modifier and Type Field Description private jnr.ffi.Pointer
changebuf
private static boolean
DEBUG
private java.util.Map<java.lang.Integer,KQSelector.Descriptor>
descriptors
private static int
EV_ADD
private static int
EV_CLEAR
private static int
EV_DELETE
private static int
EV_DISABLE
private static int
EV_ENABLE
private jnr.ffi.Pointer
eventbuf
private static int
EVFILT_READ
private static int
EVFILT_WRITE
private KQSelector.EventIO
io
private int
kqfd
private static int
MAX_EVENTS
private int[]
pipefd
private java.lang.Object
regLock
private jnr.ffi.Runtime
runtime
private java.util.Set<java.nio.channels.SelectionKey>
selected
private Native.Timespec
ZERO_TIMESPEC
-
Constructor Summary
Constructors Constructor Description KQSelector(NativeSelectorProvider provider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
handleCancelledKeys()
private void
handleChangedKey(KQSelector.Descriptor changed)
protected void
implCloseSelector()
(package private) void
interestOps(KQSelectionKey k, int ops)
java.util.Set<java.nio.channels.SelectionKey>
keys()
private int
poll(long timeout)
protected java.nio.channels.SelectionKey
register(java.nio.channels.spi.AbstractSelectableChannel ch, int ops, java.lang.Object att)
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
-
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:
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
-
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)
-
handleCancelledKeys
private int handleCancelledKeys()
-
handleChangedKey
private void handleChangedKey(KQSelector.Descriptor changed)
-
wakeupReceived
private void wakeupReceived()
-
wakeup
public java.nio.channels.Selector wakeup()
- Specified by:
wakeup
in classjava.nio.channels.Selector
-
interestOps
void interestOps(KQSelectionKey k, int ops)
-
-