mirror of
https://github.com/Azure/DotNetty.git
synced 2026-10-18 22:30:36 +08:00
f31c02e346
Motivation: TlsHandler Fix TlsHandler, optimize encryption / decryption wrt Write vs Flush semantics, optimize memory retention for sparse communication, adopt IByteBuffer.GetIoBuffers() in TlsHandler. Modifications: - TlsHandler is rewritten to use batch->copy->write approach instead of writing directly to SslStream in order to reduce overhead of framing / writing out everything separately. - TlsHandler uses IByteBuffer.GetIoBuffers intead of direct array access increasing compatibility for non-array-backed buffers. - TlsHandler and TlsHandler.MediationStream use Task semantics now when reading through SslStream. - Extra: upgraded to NBench 2.2, xUnit 2.1.0. - Extra: better portability for .NET Core support. Result: TlsHandler provides better framing and much better (x2+) performance (depends on application control of flushing). TlsHandler operates properly in edge cases when more than one frame is accepted at once and if decrypted frame size is more than 4 KB. TlsHandler holds only 256 byte buffer while waiting for more data to arrive off the wire. Extra: DotNetty is almost .NET Core compatible.
29 lines
818 B
C#
29 lines
818 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
namespace DotNetty.Tests.Common
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public static class EnumerableExtensions
|
|
{
|
|
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> src, Func<T, bool> splitFunc)
|
|
{
|
|
var group = new List<T>();
|
|
foreach (T elem in src)
|
|
{
|
|
if (splitFunc(elem))
|
|
{
|
|
yield return group;
|
|
group = new List<T>();
|
|
}
|
|
else
|
|
{
|
|
group.Add(elem);
|
|
}
|
|
}
|
|
yield return group;
|
|
}
|
|
}
|
|
} |