Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 • committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -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