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) ); int maxBufferSize; if (Config.BufferPoolMaxMemory == 0) { Config.BufferPoolMaxMemory = 500; } maxBufferSize = Config.BufferPoolMaxMemory * 1024 * 1024 / Config.BufferSize / Math.Min(Environment.ProcessorCount, 16) / 2; if (maxBufferSize < Config.BufferPoolSize) { maxBufferSize = Config.BufferPoolSize; } mReceiveBufferPoolGroup = new BufferPoolGroup(Config.BufferSize, Config.BufferPoolSize, maxBufferSize, Math.Min(Environment.ProcessorCount, 16)); mSendBufferPoolGroup = new BufferPoolGroup(Config.BufferSize, Config.BufferPoolSize, maxBufferSize, Math.Min(Environment.ProcessorCount, 16)); if (Config.SendQueueEnabled) { mSendDispatchCenter = new Dispatchs.DispatchCenter <ISession>(SessionSendData, Config.SendQueues); } mSessions = new ConcurrentDictionary <long, ISession>(); mInitialized = true; mAcceptDispatcher = new Dispatchs.DispatchCenter <Socket>( AcceptProcess, Math.Min(Environment.ProcessorCount, 16) ); if (Config.SessionTimeOut > 0) { if (Config.SessionTimeOut * 1000 < mTimeOutCheckTime) { mTimeOutCheckTime = Config.SessionTimeOut * 1000; } if (mDetectionTimer != null) { mDetectionTimer.Dispose(); } mDetectionTimer = new System.Threading.Timer( OnDetectionHandler, null, mTimeOutCheckTime, mTimeOutCheckTime ); Log(LogType.Info, null, "detection sessions timeout with {0}s", Config.SessionTimeOut); } } }
private void ToInitialize() { if (!mInitialized) { mReceiveDispatchCenter = new Dispatchs.DispatchCenter <SocketAsyncEventArgsX>(ProcessReceiveArgs, Options.IOQueues); int maxBufferSize; if (Options.BufferPoolMaxMemory == 0) { Options.BufferPoolMaxMemory = 500; } maxBufferSize = (int)(((long)Options.BufferPoolMaxMemory * 1024 * 1024) / Options.BufferSize / Options.BufferPoolGroups); if (maxBufferSize < Options.BufferPoolSize) { maxBufferSize = Options.BufferPoolSize; } mReceiveBufferPoolGroup = new BufferPoolGroup(Options.BufferSize, Options.BufferPoolSize, maxBufferSize, Options.BufferPoolGroups); mSendBufferPoolGroup = new BufferPoolGroup(Options.BufferSize, Options.BufferPoolSize, maxBufferSize, Options.BufferPoolGroups); mSessions = new ConcurrentDictionary <long, ISession>(); mInitialized = true; mAcceptDispatcher = new Dispatchs.DispatchCenter <AcceptSocketInfo>(AcceptProcess, Math.Min(Environment.ProcessorCount, 16)); if (Options.SessionTimeOut > 0) { if (Options.SessionTimeOut * 1000 < mTimeOutCheckTime) { mTimeOutCheckTime = Options.SessionTimeOut * 1000; } else { mTimeOutCheckTime = Options.SessionTimeOut * 1000; } if (mDetectionTimer != null) { mDetectionTimer.Dispose(); } mDetectionTimer = new System.Threading.Timer(OnDetectionHandler, null, mTimeOutCheckTime, mTimeOutCheckTime); if (EnableLog(LogType.Info)) { Log(LogType.Info, null, "detection sessions timeout with {0}s", Options.SessionTimeOut); } } } }
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)); } }