Skip to content

Commit 47c7efd

Browse files
committed
we don't actually need a default CycleBufferPool<T> impl;
1 parent 6270a65 commit 47c7efd

5 files changed

Lines changed: 7 additions & 34 deletions

File tree

src/RESPite/Buffers/CycleBuffer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static CycleBuffer Create(
3737

3838
private CycleBuffer(MemoryPool<byte>? pool, ICycleBufferCallback? callback = null)
3939
{
40-
_pool = pool ?? CycleBufferPool<byte>.Default;
40+
_pool = pool ?? MemoryPool<byte>.Shared;
4141
_callback = callback;
4242
leasedStart = -1;
4343
}

src/RESPite/Buffers/CycleBufferPool.cs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,6 @@ public abstract class CycleBufferPool<T> : MemoryPool<T>
5656
/// <summary>
5757
/// Create a buffer with knowledge of the existing leased data.
5858
/// </summary>
59-
public abstract IMemoryOwner<T> Rent(in ReadOnlySequence<T> existing);
60-
61-
// new MemoryPool(...) would be a non-growing buffer pool.
62-
public static CycleBufferPool<T> Default { get; } = new DefaultPool();
63-
64-
private class DefaultPool : CycleBufferPool<T>
65-
{
66-
private static readonly MemoryPool<T> Tail =
67-
#if TRACK_MEMORY
68-
MemoryTrackedPool<T>.Shared;
69-
#else
70-
MemoryPool<T>.Shared;
71-
#endif
72-
73-
// ReSharper disable once StaticMemberInGenericType - intentional to memoize, but can vary per T
74-
private static readonly int MaxSize = Tail.MaxBufferSize;
75-
76-
protected override void Dispose(bool disposing) { }
77-
78-
/// <inheritdoc/>
79-
public override IMemoryOwner<T> Rent(int minBufferSize = -1) => Tail.Rent(minBufferSize);
80-
81-
public override int MaxBufferSize => Tail.MaxBufferSize;
82-
83-
/// <inheritdoc/>
84-
public override IMemoryOwner<T> Rent(in ReadOnlySequence<T> existing)
85-
=> Tail.Rent(Math.Min(MemoryPoolExtensions.NextSize(existing), MaxSize));
86-
}
59+
public virtual IMemoryOwner<T> Rent(in ReadOnlySequence<T> existing)
60+
=> Rent(Math.Min(MemoryPoolExtensions.NextSize(existing), MaxBufferSize));
8761
}

src/RESPite/PublicAPI/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
[SER004]static RESPite.AsciiHash.EqualsCI(System.ReadOnlySpan<char> first, System.ReadOnlySpan<byte> second) -> bool
55
[SER004]static RESPite.AsciiHash.SequenceEqualsCI(System.ReadOnlySpan<byte> first, System.ReadOnlySpan<char> second) -> bool
66
[SER004]static RESPite.AsciiHash.SequenceEqualsCI(System.ReadOnlySpan<char> first, System.ReadOnlySpan<byte> second) -> bool
7-
[SER004]abstract RESPite.Buffers.CycleBufferPool<T>.Rent(in System.Buffers.ReadOnlySequence<T> existing) -> System.Buffers.IMemoryOwner<T>!
7+
[SER004]virtual RESPite.Buffers.CycleBufferPool<T>.Rent(in System.Buffers.ReadOnlySequence<T> existing) -> System.Buffers.IMemoryOwner<T>!
88
[SER004]RESPite.Buffers.CycleBuffer.Pool.get -> System.Buffers.MemoryPool<byte>!
99
[SER004]RESPite.Buffers.CycleBufferPool<T>
1010
[SER004]RESPite.Buffers.CycleBufferPool<T>.CycleBufferPool() -> void
1111
[SER004]static RESPite.Buffers.CycleBuffer.Create(System.Buffers.MemoryPool<byte>? pool = null, RESPite.Buffers.ICycleBufferCallback? callback = null) -> RESPite.Buffers.CycleBuffer
12-
[SER004]static RESPite.Buffers.CycleBufferPool<T>.Default.get -> RESPite.Buffers.CycleBufferPool<T>!

src/StackExchange.Redis/ConfigurationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ internal static bool TryParseRedisProtocol(string? value, out RedisProtocol prot
14211421
}
14221422

14231423
/// <summary>
1424-
/// The buffer pool to use when buffering responses, and for allocating <see cref="Lease{byte}"/> results.
1424+
/// The buffer pool to use when buffering responses, and for allocating <see cref="Lease{Byte}"/> results.
14251425
/// </summary>
14261426
public MemoryPool<byte>? ResponseBufferPool { get; set; }
14271427

tests/StackExchange.Redis.Tests/ConfigTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ orderby name
9090
"password",
9191
"proxy",
9292
"reconnectRetryPolicy",
93-
"RequestCycleBufferPool",
94-
"ResponseCycleBufferPool",
93+
"RequestBufferPool",
94+
"ResponseBufferPool",
9595
"responseTimeout",
9696
"ServiceName",
9797
"SocketManager",

0 commit comments

Comments
 (0)