private void ToInitialize() { if (!mInitialized) { mReceiveDispatchCenter = new Dispatchs.DispatchCenter <SocketAsyncEventArgsX>(ProcessReceiveArgs, Math.Min(Environment.ProcessorCount, 16)); mBufferPoolGroup = new BufferPoolGroup(Config.BufferSize, Config.BufferPoolSize, Math.Min(Environment.ProcessorCount, 16), IO_Completed); if (Config.SendQueueEnabled) { mSendDispatchCenter = new Dispatchs.DispatchCenter <ISession>(SessionSendData, Config.SendQueues); } mSessions = new ConcurrentDictionary <long, ISession>(); mInitialized = true; mWatch.Restart(); mSessionDetector.Timeout = OnSessionDetection; mAcceptDispatcher = new Dispatchs.MultiThreadDispatcher <Socket>(AcceptProcess, 10, Math.Min(Environment.ProcessorCount, 16)); if (Config.DetectionTime > 0) { if (mDetectionTimer != null) { mDetectionTimer.Dispose(); } mDetectionTimer = new System.Threading.Timer(OnDetectionHandler, null, Config.DetectionTime * 1000, Config.DetectionTime * 1000); if (EnableLog(LogType.Info)) { Log(LogType.Info, null, "detection sessions timeout with {0}s", Config.DetectionTime); } } } }
private void ToInitialize() { if (!mInitialized) { mReceiveDispatchCenter = new Dispatchs.DispatchCenter <SocketAsyncEventArgsX>(ProcessReceiveArgs, Math.Min(Environment.ProcessorCount, 16)); mBufferPoolGroup = new BufferPoolGroup(Config.BufferSize, Config.BufferPoolSize, Math.Min(Environment.ProcessorCount, 16), IO_Completed); if (Config.SendQueueEnabled) { mSendDispatchCenter = new Dispatchs.DispatchCenter <ISession>(SessionSendData, Config.SendQueues); } mSessions = new ConcurrentDictionary <long, ISession>(); //new Dictionary<long, ISession>(Config.MaxConnections * 2); mInitialized = true; mWatch.Restart(); mSessionDetector.Timeout = OnSessionDetection; mSessionDetector.Server = this; mAcceptDispatcher = new Dispatchs.MultiThreadDispatcher <Socket>(AcceptProcess, 10, Math.Min(Environment.ProcessorCount, 16)); } }
private void ToInitialize() { if (!mInitialized) { if (Config.ReceiveQueueEnabled) { mReceiveDispatchCenter = new Dispatchs.DispatchCenter <SocketAsyncEventArgsX>(ProcessReceiveArgs, Config.ReceiveQueues); mReceiveDispatchCenter.Start(); } if (Config.SendQueueEnabled) { mSendDispatchCenter = new Dispatchs.DispatchCenter <ISession>(SessionSendData, Config.SendQueues); mSendDispatchCenter.Start(); } mBufferPool = new BufferPool(Config.BufferSize, Config.BufferPoolSize, IO_Completed); mReceiveBufferPool = new BufferPool(Config.BufferSize, 1024, IO_Completed); mSessions = new Dictionary <long, ISession>(Config.MaxConnections * 2); mInitialized = true; mWatch.Restart(); mSessionDetector.Timeout = OnSessionDetection; mSessionDetector.Server = this; mAcceptDispatcher = new Dispatchs.MultiThreadDispatcher <Socket>(AcceptProcess, 10, Config.MaxAcceptThreads); } }