Targets .NET Core 3.0 (#39)

This commit is contained in:
Kamron Batman 2019-08-02 17:53:18 -07:00 • committed by GitHub
parent 0993c03b70
commit 08bf44af9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
125 changed files with 1473 additions and 14244 deletions

View file

@ -19,9 +19,9 @@
***************************************************************************/
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Threading;
using Server.Network;
namespace Server
{
@ -30,7 +30,6 @@ namespace Server
public sealed class FileQueue : IDisposable
{
private static int bufferSize;
private static BufferPool bufferPool;
private Chunk[] active;
private int activeCount;
@ -47,15 +46,14 @@ namespace Server
static FileQueue()
{
bufferSize = FileOperations.BufferSize;
bufferPool = new BufferPool("File Buffers", 64, bufferSize);
}
public FileQueue(int concurrentWrites, FileCommitCallback callback)
{
if (concurrentWrites < 1) throw new ArgumentOutOfRangeException("concurrentWrites");
if (bufferSize < 1) throw new ArgumentOutOfRangeException("bufferSize");
if (callback == null) throw new ArgumentNullException("callback");
if (bufferSize < 1)
throw new ArgumentOutOfRangeException("bufferSize");
syncRoot = new object();
@ -139,7 +137,7 @@ namespace Server
{
if (active[slot] != chunk) throw new ArgumentException();
bufferPool.ReleaseBuffer(chunk.Buffer);
ArrayPool<byte>.Shared.Return(chunk.Buffer);
if (pending.Count > 0)
{
@ -172,7 +170,8 @@ namespace Server
while (size > 0)
{
if (buffered.buffer == null) buffered.buffer = bufferPool.AcquireBuffer();
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
@ -229,4 +228,4 @@ namespace Server
public int length;
}
}
}
}