net_io.core.NetChannelPool Maven / Gradle / Ivy
The newest version!
package net_io.core;
import java.io.IOException;
import java.nio.channels.SocketChannel;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import net_io.utils.MemoryQueueCache;
import net_io.utils.NetLog;
class NetChannelPool {
// 管理线程ID(所有管理线程中唯一)
private static AtomicLong threadID = new AtomicLong(0);
// 内存缓存时间:5秒
protected static final long CACHE_TIME = 5 * 1000;
// 新注册的Channel的序列号(全局唯一)
private static AtomicLong requestChannelSequence = new AtomicLong(0);
// 管理线程(定时器)
private Timer timer = new Timer("NetChannelPool-"+threadID.incrementAndGet(), true);
// Channel信息
private ConcurrentHashMap chMap;
//内存缓存对象
protected MemoryQueueCache