private void Initialize() { int pipeLineDeph = 16; int connections = 1024; _sendPool = new RioFixedBufferPool(10 * connections, 140 * pipeLineDeph); _receivePool = new RioFixedBufferPool(10 * connections, 128 * pipeLineDeph); _listener = new RioTcpListener(_sendPool, _receivePool, 1024); _listener.OnAccepted = (acceptedSocket) => { Task.Run(async() => { await Process(acceptedSocket); }) .Forget(); }; }
private void Initialize() { _bufferManager = new GrowingByteBufferManager(_configuration.InitialPooledBufferCount, _configuration.ReceiveBufferSize); int pipeLineDeph = 16; int connections = 1024; _sendPool = new RioFixedBufferPool(10 * connections, 140 * pipeLineDeph); _receivePool = new RioFixedBufferPool(10 * connections, 128 * pipeLineDeph); _listener = new RioTcpListener(_sendPool, _receivePool, 1024); _listener.OnAccepted = (acceptedSocket) => { Task.Run(async() => { await Process(acceptedSocket); }) .Forget(); }; }
public void Shutdown() { if (Interlocked.Exchange(ref _state, _disposed) == _disposed) { return; } try { _listener.Dispose(); _listener = null; Task.Factory.StartNew(async() => { try { foreach (var session in _sessions.Values) { await session.Close(); } } catch (Exception ex) when(!ShouldThrow(ex)) { } }, TaskCreationOptions.PreferFairness) .Wait(); _sendPool.Dispose(); _receivePool.Dispose(); _sendPool = null; _receivePool = null; } catch (Exception ex) when(!ShouldThrow(ex)) { } }
private void Initialize() { _bufferManager = new GrowingByteBufferManager(_configuration.InitialBufferAllocationCount, _configuration.ReceiveBufferSize); int pipeLineDeph = 16; int connections = 1024; _sendPool = new RioFixedBufferPool(10 * connections, 140 * pipeLineDeph); _receivePool = new RioFixedBufferPool(10 * connections, 128 * pipeLineDeph); _listener = new RioTcpListener(_sendPool, _receivePool, 1024); _listener.OnAccepted = (acceptedSocket) => { Task.Run(async () => { await Process(acceptedSocket); }) .Forget(); }; }
public void Shutdown() { if (Interlocked.Exchange(ref _state, _disposed) == _disposed) { return; } try { _listener.Dispose(); _listener = null; Task.Run(async () => { try { foreach (var session in _sessions.Values) { await session.Close(); } } catch (Exception ex) when (!ShouldThrow(ex)) { } }) .Wait(); _sendPool.Dispose(); _receivePool.Dispose(); _sendPool = null; _receivePool = null; } catch (Exception ex) when (!ShouldThrow(ex)) { } }