This reverts commit 179cb50557.
This commit is contained in:
parent
179cb50557
commit
c2ecc76457
588 changed files with 16260 additions and 10926 deletions
|
|
@ -23,7 +23,7 @@ using System.Buffers;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public delegate void FileCommitCallback(FileQueue.Chunk chunk);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ namespace Server.Persistence
|
|||
|
||||
public FileQueue(int concurrentWrites, FileCommitCallback callback)
|
||||
{
|
||||
if (concurrentWrites < 1) throw new ArgumentOutOfRangeException(nameof(concurrentWrites));
|
||||
if (concurrentWrites < 1) throw new ArgumentOutOfRangeException("concurrentWrites");
|
||||
|
||||
if (bufferSize < 1)
|
||||
throw new ArgumentOutOfRangeException("bufferSize");
|
||||
|
|
@ -134,7 +134,7 @@ namespace Server.Persistence
|
|||
{
|
||||
if (active[slot] != chunk) throw new ArgumentException();
|
||||
|
||||
ArrayPool<byte>.Shared.Return(chunk.Buffer, true);
|
||||
ArrayPool<byte>.Shared.Return(chunk.Buffer);
|
||||
|
||||
if (pending.Count > 0)
|
||||
{
|
||||
|
|
@ -157,17 +157,18 @@ namespace Server.Persistence
|
|||
|
||||
public void Enqueue(byte[] buffer, int offset, int size)
|
||||
{
|
||||
if (buffer == null) throw new ArgumentNullException(nameof(buffer));
|
||||
if (buffer == null) throw new ArgumentNullException("buffer");
|
||||
|
||||
if (offset < 0) throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
if (size < 0) throw new ArgumentOutOfRangeException(nameof(size));
|
||||
if (offset < 0) throw new ArgumentOutOfRangeException("offset");
|
||||
if (size < 0) throw new ArgumentOutOfRangeException("size");
|
||||
if (buffer.Length - offset < size) throw new ArgumentException();
|
||||
|
||||
Position += size;
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
buffered.buffer ??= ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
if (buffered.buffer == null)
|
||||
buffered.buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
|
||||
byte[] page = buffered.buffer; // buffer page
|
||||
int pageSpace = page.Length - buffered.length; // available bytes in page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue