Package com.barchart.udt.nio
Class SelectorUDT
java.lang.Object
java.nio.channels.Selector
java.nio.channels.spi.AbstractSelector
com.barchart.udt.nio.SelectorUDT
- All Implemented Interfaces:
Closeable,AutoCloseable
selector
design guidelines:
1) follow general contracts of jdk 6 nio; see barchart-udt-reference-jdk6
2) adapt to how netty is doing select; see NioEventLoop
note: you must use SelectorProviderUDT.openSelector() to obtain
instance of this class; do not use JDK
Selector.open()
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EpollUDTprotected static final org.slf4j.Loggerfinal intprivate final IntBufferlist of epoll sockets with read interestprivate final ConcurrentMap<Integer, SelectionKeyUDT> [ socket-id : selection-key ]private final Set<? extends SelectionKey> public view : immutableprivate inttracks correlation read with write for the same keyprivate final ConcurrentMap<SelectionKeyUDT, SelectionKeyUDT> set of keys with data ready for an operationprivate final Set<? extends SelectionKey> public view : removal allowed, but not additionprivate final Lockselect is exclusiveprivate final IntBufferreported epoll socket list sizesprivate final ConcurrentMap<SelectionKeyUDT, SelectionKeyUDT> Canceled keys.private intguarded byinvalid reference
#doSelectLockedprivate intprivate final IntBufferlist of epoll sockets with write interest -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSelectorUDT(SelectorProvider provider, int maximumSelectorSize) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcancel(SelectionKeyUDT keyUDT) Enqueue cancel request.protected voiddoCancel()Process pending cancel requests.protected intdoEpollEnter(long millisTimeout) protected intdoEpollExclusive(long millisTimeout) protected intdoEpollSelect(long millisTimeout) protected intdoEpollSelectUDT(long timeout) protected voidprotected voiddoResultsRead(int resultIndex) protected voiddoResultsWrite(int resultIndex) protected EpollUDTepollUDT()protected voidkeys()protected voidlogSocketId(String title, int socketId) protected static Selectoruse this call to instantiate a selector for UDTprotected SelectionKeyregister(AbstractSelectableChannel channel, int interestOps, Object attachment) intselect()intselect(long timeout) intwakeup()protected booleanprotected voidMethods inherited from class java.nio.channels.spi.AbstractSelector
begin, cancelledKeys, close, deregister, end, isOpen, provider
-
Field Details
-
log
protected static final org.slf4j.Logger log -
epollUDT
-
maximimSelectorSize
public final int maximimSelectorSize -
readBuffer
list of epoll sockets with read interest -
registeredKeyMap
[ socket-id : selection-key ] -
registeredKeySet
public view : immutable -
resultIndex
private volatile int resultIndextracks correlation read with write for the same key -
selectedKeyMap
set of keys with data ready for an operation -
selectedKeySet
public view : removal allowed, but not addition -
selectLock
select is exclusive -
sizeBuffer
reported epoll socket list sizes -
terminatedKeyMap
Canceled keys. -
wakeupBaseCount
private volatile int wakeupBaseCountguarded byinvalid reference
#doSelectLocked -
wakeupStepCount
private volatile int wakeupStepCount -
writeBuffer
list of epoll sockets with write interest
-
-
Constructor Details
-
SelectorUDT
- Throws:
ExceptionUDT
-
-
Method Details
-
open
use this call to instantiate a selector for UDT- Throws:
IOException
-
cancel
Enqueue cancel request. -
doCancel
protected void doCancel()Process pending cancel requests. -
doEpollEnter
- Parameters:
millisTimeout- invalid input: '<'0 : invinite; =0 : immediate; >0 : finite;- Throws:
IOException
-
doEpollExclusive
- Parameters:
millisTimeout- invalid input: '<'0 : invinite; =0 : immediate; >0 : finite;- Returns:
- invalid input: '<'0 : should not happen =0 : means nothing was selected/timeout >0 : number of selected keys
- Throws:
IOException
-
doEpollSelect
- Parameters:
millisTimeout- invalid input: '<'0 : infinite =0 : immediate >0 : finite- Throws:
ExceptionUDT
-
doEpollSelectUDT
- Throws:
ExceptionUDT
-
doResults
protected void doResults() -
doResultsRead
protected void doResultsRead(int resultIndex) -
doResultsWrite
protected void doResultsWrite(int resultIndex) -
epollUDT
-
implCloseSelector
- Specified by:
implCloseSelectorin classAbstractSelector- Throws:
IOException
-
keys
-
logSocketId
-
register
protected SelectionKey register(AbstractSelectableChannel channel, int interestOps, Object attachment) - Specified by:
registerin classAbstractSelector
-
select
- Specified by:
selectin classSelector- Throws:
IOException
-
select
- Specified by:
selectin classSelector- Throws:
IOException
-
selectedKeys
- Specified by:
selectedKeysin classSelector
-
selectNow
- Specified by:
selectNowin classSelector- Throws:
IOException
-
wakeup
-
wakeupIsPending
protected boolean wakeupIsPending() -
wakeupMarkBase
protected void wakeupMarkBase()
-