LISTENER
- 监听器类型public abstract class AbstractNioEventProcessor<LISTENER extends IListener<INioSession>> extends Thread implements INioEventProcessor<INioSession>
Thread.State, Thread.UncaughtExceptionHandler
MAX_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, yield
public AbstractNioEventProcessor(String name, INioEventGroup<LISTENER> eventGroup, long selectTimeout) throws IOException
IOException
public void start()
INioEventProcessor
start
in interface INioEventProcessor<INioSession>
start
in class Thread
public void close() throws IOException
close
in interface AutoCloseable
IOException
public void registerEvent(SelectableChannel channel, int ops, INioSession session) throws IOException
INioEventProcessor
registerEvent
in interface INioEventProcessor<INioSession>
channel
- 多路复用频道ops
- 操作标识session
- 会话对象IOException
- 可能产生的IO异常public void unregisterEvent(INioSession session)
INioEventProcessor
unregisterEvent
in interface INioEventProcessor<INioSession>
session
- 会话对象public Selector selector()
INioEventProcessor
selector
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.