Improve XML documentation coverage across src modules and sync generated analysis artifacts.
This commit is contained in:
@@ -23,8 +23,11 @@ public sealed class OutboundBufferPool
|
||||
private long _returnCount;
|
||||
private long _broadcastCount;
|
||||
|
||||
/// <summary>Total buffer rent operations served by the pool.</summary>
|
||||
public long RentCount => Interlocked.Read(ref _rentCount);
|
||||
/// <summary>Total buffer return operations accepted by the pool.</summary>
|
||||
public long ReturnCount => Interlocked.Read(ref _returnCount);
|
||||
/// <summary>Total broadcast-drain operations performed.</summary>
|
||||
public long BroadcastCount => Interlocked.Read(ref _broadcastCount);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -36,6 +39,7 @@ public sealed class OutboundBufferPool
|
||||
/// <paramref name="size"/> bytes. Tries the internal pool first; falls back to
|
||||
/// <see cref="MemoryPool{T}.Shared"/>.
|
||||
/// </summary>
|
||||
/// <param name="size">Minimum required buffer size.</param>
|
||||
public IMemoryOwner<byte> Rent(int size)
|
||||
{
|
||||
Interlocked.Increment(ref _rentCount);
|
||||
@@ -70,6 +74,7 @@ public sealed class OutboundBufferPool
|
||||
/// <paramref name="size"/> bytes. The caller is responsible for calling
|
||||
/// <see cref="ReturnBuffer"/> when finished.
|
||||
/// </summary>
|
||||
/// <param name="size">Minimum required buffer size.</param>
|
||||
public byte[] RentBuffer(int size)
|
||||
{
|
||||
Interlocked.Increment(ref _rentCount);
|
||||
@@ -94,6 +99,7 @@ public sealed class OutboundBufferPool
|
||||
/// Returns <paramref name="buffer"/> to the appropriate tier so it can be
|
||||
/// reused by a subsequent <see cref="RentBuffer"/> call.
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer previously rented from this pool.</param>
|
||||
public void ReturnBuffer(byte[] buffer)
|
||||
{
|
||||
Interlocked.Increment(ref _returnCount);
|
||||
@@ -128,6 +134,8 @@ public sealed class OutboundBufferPool
|
||||
///
|
||||
/// Go reference: client.go — broadcast flush coalescing for fan-out.
|
||||
/// </summary>
|
||||
/// <param name="pendingWrites">Pending write segments to coalesce.</param>
|
||||
/// <param name="destination">Destination buffer receiving the concatenated payloads.</param>
|
||||
public int BroadcastDrain(IReadOnlyList<ReadOnlyMemory<byte>> pendingWrites, byte[] destination)
|
||||
{
|
||||
var offset = 0;
|
||||
@@ -144,6 +152,7 @@ public sealed class OutboundBufferPool
|
||||
/// Returns the total number of bytes needed to coalesce all
|
||||
/// <paramref name="pendingWrites"/> into a single buffer.
|
||||
/// </summary>
|
||||
/// <param name="pendingWrites">Pending write segments to size.</param>
|
||||
public static int CalculateBroadcastSize(IReadOnlyList<ReadOnlyMemory<byte>> pendingWrites)
|
||||
{
|
||||
var total = 0;
|
||||
@@ -164,15 +173,22 @@ public sealed class OutboundBufferPool
|
||||
private readonly ConcurrentBag<byte[]> _pool;
|
||||
private byte[]? _buffer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a pooled memory owner backed by a reusable byte array.
|
||||
/// </summary>
|
||||
/// <param name="buffer">Rented backing buffer.</param>
|
||||
/// <param name="pool">Pool to return the buffer to on disposal.</param>
|
||||
public PooledMemoryOwner(byte[] buffer, ConcurrentBag<byte[]> pool)
|
||||
{
|
||||
_buffer = buffer;
|
||||
_pool = pool;
|
||||
}
|
||||
|
||||
/// <summary>Memory view over the currently owned buffer.</summary>
|
||||
public Memory<byte> Memory =>
|
||||
_buffer is { } b ? b.AsMemory() : Memory<byte>.Empty;
|
||||
|
||||
/// <summary>Returns the owned buffer to the originating pool.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _buffer, null) is { } b)
|
||||
|
||||
Reference in New Issue
Block a user