class EventPumper extends Object implements Runnable
This class is optimized for minimal overhead and maximum event dispatch efficiency.
All hot paths (e.g., processRead(java.nio.channels.SelectionKey), processWrite(java.nio.channels.SelectionKey), runDelayedEvents())
avoid synchronization, allocations, and unnecessary syscalls.
Key performance characteristics:
wakeup() on pending I/O (no cooldown)ConcurrentHashSet| Constructor and Description |
|---|
EventPumper(RouterContext ctx,
NTCPTransport transport) |
| Modifier and Type | Method and Description |
|---|---|
static ByteBuffer |
acquireBuf()
High-frequency path in thread.
|
void |
blockIP(byte[] ip) |
static void |
clearInterest(SelectionKey key,
int op) |
long |
getIdleTimeout() |
boolean |
isAlive()
Selector can take quite a while to close after calling stopPumping()
|
boolean |
processWrite(NTCPConnection con,
SelectionKey key) |
void |
register(ServerSocketChannel chan)
Register the acceptor.
|
void |
registerConnect(NTCPConnection con)
Outbound connection registration with optional retry backoff.
|
static void |
releaseBuf(ByteBuffer buf)
Return a read buffer to the pool.
|
void |
run() |
static void |
setInterest(SelectionKey key,
int op) |
void |
startPumping() |
void |
stopPumping() |
void |
wantsRead(NTCPConnection con)
This is only called from NTCPConnection.complete()
if there is more data, which is rare (never?)
so we don't need to check for dups or make _wantsRead a Set.
|
void |
wantsWrite(NTCPConnection con)
Called by the connection when it has data ready to write (after bw allocation).
|
public EventPumper(RouterContext ctx, NTCPTransport transport)
public static ByteBuffer acquireBuf()
public void blockIP(byte[] ip)
public static void clearInterest(SelectionKey key, int op) throws CancelledKeyException
CancelledKeyExceptionpublic long getIdleTimeout()
public boolean isAlive()
public boolean processWrite(NTCPConnection con, SelectionKey key)
public void register(ServerSocketChannel chan)
public void registerConnect(NTCPConnection con)
public static void releaseBuf(ByteBuffer buf)
public static void setInterest(SelectionKey key, int op) throws CancelledKeyException
CancelledKeyExceptionpublic void startPumping()
public void stopPumping()
public void wantsRead(NTCPConnection con)
public void wantsWrite(NTCPConnection con)