LISTENER - 监听器类型public abstract class AbstractNioEventProcessor<LISTENER extends IListener<INioSession>> extends Thread implements INioEventProcessor<INioSession>
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
AbstractNioEventProcessor(String name,
INioEventGroup<LISTENER> eventGroup,
long selectTimeout) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract INioSession |
buildNioSession(INioEventGroup<LISTENER> eventGroup,
SelectableChannel channel)
由子类实现创建会话的具体逻辑
|
void |
close() |
void |
interrupt() |
protected void |
onExceptionEvent(SelectionKey key,
Throwable e) |
protected abstract void |
onReadEvent(SelectionKey key)
由子类实现通道读逻辑
|
protected abstract void |
onWriteEvent(SelectionKey key)
由子类实现通道写逻辑
|
void |
registerEvent(SelectableChannel channel,
int ops,
INioSession session)
注册事件
|
void |
run() |
Selector |
selector()
获取选择器
|
void |
start()
启动
|
void |
unregisterEvent(INioSession session)
解注册事件
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yieldpublic AbstractNioEventProcessor(String name, INioEventGroup<LISTENER> eventGroup, long selectTimeout) throws IOException
IOExceptionpublic void start()
INioEventProcessorstart in interface INioEventProcessor<INioSession>start in class Threadpublic void close()
throws IOException
close in interface AutoCloseableIOExceptionpublic void registerEvent(SelectableChannel channel, int ops, INioSession session) throws IOException
INioEventProcessorregisterEvent in interface INioEventProcessor<INioSession>channel - 多路复用频道ops - 操作标识session - 会话对象IOException - 可能产生的IO异常public void unregisterEvent(INioSession session)
INioEventProcessorunregisterEvent in interface INioEventProcessor<INioSession>session - 会话对象public Selector selector()
INioEventProcessorselector in interface INioEventProcessor<INioSession>protected void onExceptionEvent(SelectionKey key, Throwable e)
protected abstract INioSession buildNioSession(INioEventGroup<LISTENER> eventGroup, SelectableChannel channel)
eventGroup - 多路复用通道事件处理器channel - 通道protected abstract void onReadEvent(SelectionKey key) throws IOException
key - 选择键IOException - 可能产生的I/O异常protected abstract void onWriteEvent(SelectionKey key) throws IOException
key - 选择键IOException - 可能产生的I/O异常Copyright © 2022. All rights reserved.