private static PipeOptions GetInputPipeOptions(ServiceContext serviceContext, MemoryPool <byte> memoryPool, PipeScheduler writerScheduler) => new PipeOptions ( pool: memoryPool, readerScheduler: serviceContext.Scheduler, writerScheduler: writerScheduler, pauseWriterThreshold: serviceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0, resumeWriterThreshold: serviceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0, useSynchronizationContext: false, minimumSegmentSize: memoryPool.GetMinimumSegmentSize() );
private static PipeOptions GetOutputPipeOptions(ServiceContext serviceContext, MemoryPool <byte> memoryPool, PipeScheduler readerScheduler) => new PipeOptions ( pool: memoryPool, readerScheduler: readerScheduler, writerScheduler: serviceContext.Scheduler, pauseWriterThreshold: GetOutputResponseBufferSize(serviceContext), resumeWriterThreshold: GetOutputResponseBufferSize(serviceContext), useSynchronizationContext: false, minimumSegmentSize: memoryPool.GetMinimumSegmentSize() );
private SslDuplexPipe CreateSslDuplexPipe(IDuplexPipe transport, MemoryPool <byte> memoryPool) { var inputPipeOptions = new StreamPipeReaderOptions ( pool: memoryPool, bufferSize: memoryPool.GetMinimumSegmentSize(), minimumReadSize: memoryPool.GetMinimumAllocSize(), leaveOpen: true ); var outputPipeOptions = new StreamPipeWriterOptions ( pool: memoryPool, leaveOpen: true ); return(new SslDuplexPipe(transport, inputPipeOptions, outputPipeOptions, _sslStreamFactory)); }
public static int GetMinimumAllocSize(this MemoryPool <byte> pool) { // 1/2 of a segment return(pool.GetMinimumSegmentSize() / 2); }
// 1/2 of a segment public static int GetMinimumAllocSize(this MemoryPool <byte> pool) => pool.GetMinimumSegmentSize() / 2;