NetworkReader/WriterPool: .pool renamed to .Pool

This commit is contained in:
vis2k 2021-02-18 14:40:38 +08:00
parent 409eac092d
commit 73d95f9b5b
2 changed files with 7 additions and 7 deletions

View File

@ -21,7 +21,7 @@ public static class NetworkReaderPool
// reuse Pool<T>
// we still wrap it in NetworkReaderPool.Get/Recyle so we can reset the
// position and array before reusing.
static readonly Pool<PooledNetworkReader> pool = new Pool<PooledNetworkReader>(
static readonly Pool<PooledNetworkReader> Pool = new Pool<PooledNetworkReader>(
// byte[] will be assigned in GetReader
() => new PooledNetworkReader(new byte[]{})
);
@ -33,7 +33,7 @@ public static class NetworkReaderPool
public static PooledNetworkReader GetReader(byte[] bytes)
{
// grab from pool & set buffer
PooledNetworkReader reader = pool.Take();
PooledNetworkReader reader = Pool.Take();
reader.buffer = new ArraySegment<byte>(bytes);
reader.Position = 0;
return reader;
@ -46,7 +46,7 @@ public static PooledNetworkReader GetReader(byte[] bytes)
public static PooledNetworkReader GetReader(ArraySegment<byte> segment)
{
// grab from pool & set buffer
PooledNetworkReader reader = pool.Take();
PooledNetworkReader reader = Pool.Take();
reader.buffer = segment;
reader.Position = 0;
return reader;
@ -58,7 +58,7 @@ public static PooledNetworkReader GetReader(ArraySegment<byte> segment)
/// </summary>
public static void Recycle(PooledNetworkReader reader)
{
pool.Return(reader);
Pool.Return(reader);
}
}
}

View File

@ -21,7 +21,7 @@ public static class NetworkWriterPool
// position before reusing.
// this is also more consistent with NetworkReaderPool where we need to
// assign the internal buffer before reusing.
static readonly Pool<PooledNetworkWriter> pool = new Pool<PooledNetworkWriter>(
static readonly Pool<PooledNetworkWriter> Pool = new Pool<PooledNetworkWriter>(
() => new PooledNetworkWriter()
);
@ -32,7 +32,7 @@ public static class NetworkWriterPool
public static PooledNetworkWriter GetWriter()
{
// grab from pool & reset position
PooledNetworkWriter writer = pool.Take();
PooledNetworkWriter writer = Pool.Take();
writer.Reset();
return writer;
}
@ -43,7 +43,7 @@ public static PooledNetworkWriter GetWriter()
/// </summary>
public static void Recycle(PooledNetworkWriter writer)
{
pool.Return(writer);
Pool.Return(writer);
}
}
}