This reverts commit 179cb50557.
This commit is contained in:
parent
179cb50557
commit
c2ecc76457
588 changed files with 16260 additions and 10926 deletions
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
using System.IO;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public sealed class BinaryMemoryWriter : BinaryFileWriter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
using System.Threading;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public sealed class DualSaveStrategy : StandardSaveStrategy
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ using System;
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public sealed class DynamicSaveStrategy : SaveStrategy
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,9 +18,16 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace Server.Persistence
|
||||
using System;
|
||||
using System.IO;
|
||||
#if !MONO
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public static class FileOperations
|
||||
{
|
||||
|
|
@ -31,8 +38,12 @@ namespace Server.Persistence
|
|||
|
||||
public static int Concurrency{ get; set; } = 1;
|
||||
|
||||
public static bool Unbuffered{ get; set; } = true;
|
||||
|
||||
public static bool AreSynchronous => Concurrency < 1;
|
||||
|
||||
public static bool AreAsynchronous => Concurrency > 0;
|
||||
|
||||
public static FileStream OpenSequentialStream(string path, FileMode mode, FileAccess access, FileShare share)
|
||||
{
|
||||
FileOptions options = FileOptions.SequentialScan;
|
||||
|
|
@ -93,5 +104,6 @@ namespace Server.Persistence
|
|||
internal static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode,
|
||||
IntPtr securityAttrs, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public sealed class ParallelSaveStrategy : SaveStrategy
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.IO;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public static class Persistence
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public sealed class QueuedMemoryWriter : BinaryFileWriter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public abstract class SaveStrategy
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public sealed class SequentialFileWriter : Stream
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server.Persistence
|
||||
namespace Server
|
||||
{
|
||||
public class StandardSaveStrategy : SaveStrategy
|
||||
{
|
||||
|
|
@ -90,7 +91,7 @@ namespace Server.Persistence
|
|||
|
||||
idx.Write((int)(bin.Position - start));
|
||||
|
||||
m.ClearProperties();
|
||||
m.FreeCache();
|
||||
}
|
||||
|
||||
tdb.Write(World.m_MobileTypes.Count);
|
||||
|
|
@ -143,7 +144,7 @@ namespace Server.Persistence
|
|||
|
||||
idx.Write((int)(bin.Position - start));
|
||||
|
||||
item.ClearProperties();
|
||||
item.FreeCache();
|
||||
}
|
||||
|
||||
tdb.Write(World.m_ItemTypes.Count);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue