public TcpServerChannelManager(TcpServer server, IPacketizerFactory packetizerFactory) { if (server == null) { throw new ArgumentNullException("server"); } //保存当前通道管理器所属的服务器对象 _server = server; //保存当前通道管理器的协议解析器工厂 _packetizerFactory = packetizerFactory; //创建活动通道池 _activedChannels = new ConcurrentDictionary <int, TcpServerChannel>(); //挂载服务器的接受事件 _server.Accepted += new EventHandler <ChannelEventArgs>(Server_Accepted); //创建通道对象池 _channelPool = new Collections.ObjectPool <TcpServerChannel>(() => { var channel = this.CreateChannel(System.Threading.Interlocked.Increment(ref _channelId)); if (channel != null && channel.Packetizer == null && _packetizerFactory != null) { channel.Packetizer = _packetizerFactory.GetPacketizer(channel); } return(channel); }, null); }
public TcpServerChannelManager(TcpServer server, IPacketizerFactory packetizerFactory) { if(server == null) throw new ArgumentNullException("server"); //保存当前通道管理器所属的服务器对象 _server = server; //保存当前通道管理器的协议解析器工厂 _packetizerFactory = packetizerFactory; //创建活动通道池 _activedChannels = new ConcurrentDictionary<int, TcpServerChannel>(); //挂载服务器的接受事件 _server.Accepted += new EventHandler<ChannelEventArgs>(Server_Accepted); //创建通道对象池 _channelPool = new Collections.ObjectPool<TcpServerChannel>(() => { var channel = this.CreateChannel(System.Threading.Interlocked.Increment(ref _channelId)); if(channel != null && channel.Packetizer == null && _packetizerFactory != null) { channel.Packetizer = _packetizerFactory.GetPacketizer(channel); } return channel; }, null); }
protected RedisObjectBase(string name, Zongsoft.Collections.ObjectPool<ServiceStack.Redis.IRedisClient> redisPool) { if(string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException("name"); if(redisPool == null) throw new ArgumentNullException("redisPool"); _name = name.Trim(); _redisPool = redisPool; }
protected virtual void Dispose(bool disposing) { _redisPool = null; }