Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -40,44 +40,30 @@ namespace Server {
|
|||
}
|
||||
#endif
|
||||
|
||||
private static int bufferSize = 1 * MB;
|
||||
private static int concurrency = 1;
|
||||
public static int BufferSize { get; set; } = 1 * MB;
|
||||
|
||||
private static bool unbuffered = true;
|
||||
public static int Concurrency { get; set; } = 1;
|
||||
|
||||
public static int BufferSize {
|
||||
get => bufferSize;
|
||||
set => bufferSize = value;
|
||||
}
|
||||
public static bool Unbuffered { get; set; } = true;
|
||||
|
||||
public static int Concurrency {
|
||||
get => concurrency;
|
||||
set => concurrency = value;
|
||||
}
|
||||
public static bool AreSynchronous => ( Concurrency < 1 );
|
||||
|
||||
public static bool Unbuffered {
|
||||
get => unbuffered;
|
||||
set => unbuffered = value;
|
||||
}
|
||||
|
||||
public static bool AreSynchronous => ( concurrency < 1 );
|
||||
|
||||
public static bool AreAsynchronous => ( concurrency > 0 );
|
||||
public static bool AreAsynchronous => ( Concurrency > 0 );
|
||||
|
||||
public static FileStream OpenSequentialStream( string path, FileMode mode, FileAccess access, FileShare share ) {
|
||||
FileOptions options = FileOptions.SequentialScan;
|
||||
|
||||
if ( concurrency > 0 ) {
|
||||
if ( Concurrency > 0 ) {
|
||||
options |= FileOptions.Asynchronous;
|
||||
}
|
||||
|
||||
#if MONO
|
||||
return new FileStream( path, mode, access, share, bufferSize, options );
|
||||
#else
|
||||
if ( unbuffered ) {
|
||||
if ( Unbuffered ) {
|
||||
options |= NoBuffering;
|
||||
} else {
|
||||
return new FileStream( path, mode, access, share, bufferSize, options );
|
||||
return new FileStream( path, mode, access, share, BufferSize, options );
|
||||
}
|
||||
|
||||
SafeFileHandle fileHandle = UnsafeNativeMethods.CreateFile(path, (int)access, share, IntPtr.Zero, mode, (int)options, IntPtr.Zero);
|
||||
|
|
@ -86,7 +72,7 @@ namespace Server {
|
|||
throw new IOException();
|
||||
}
|
||||
|
||||
return new UnbufferedFileStream( fileHandle, access, bufferSize, ( concurrency > 0 ) );
|
||||
return new UnbufferedFileStream( fileHandle, access, BufferSize, ( Concurrency > 0 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -100,11 +86,11 @@ namespace Server {
|
|||
}
|
||||
|
||||
public override void Write( byte[] array, int offset, int count ) {
|
||||
base.Write( array, offset, bufferSize );
|
||||
base.Write( array, offset, BufferSize );
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginWrite( byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject ) {
|
||||
return base.BeginWrite( array, offset, bufferSize, userCallback, stateObject );
|
||||
return base.BeginWrite( array, offset, BufferSize, userCallback, stateObject );
|
||||
}
|
||||
|
||||
protected override void Dispose( bool disposing ) {
|
||||
|
|
|
|||
|
|
@ -31,23 +31,21 @@ namespace Server {
|
|||
private FileQueue owner;
|
||||
private int slot;
|
||||
|
||||
private byte[] buffer;
|
||||
private int offset;
|
||||
private int size;
|
||||
|
||||
public byte[] Buffer => buffer;
|
||||
public byte[] Buffer { get; }
|
||||
|
||||
public int Offset => 0;
|
||||
|
||||
public int Size => size;
|
||||
public int Size { get; }
|
||||
|
||||
public Chunk( FileQueue owner, int slot, byte[] buffer, int offset, int size ) {
|
||||
this.owner = owner;
|
||||
this.slot = slot;
|
||||
|
||||
this.buffer = buffer;
|
||||
this.Buffer = buffer;
|
||||
this.offset = offset;
|
||||
this.size = size;
|
||||
this.Size = size;
|
||||
}
|
||||
|
||||
public void Commit() {
|
||||
|
|
@ -80,9 +78,7 @@ namespace Server {
|
|||
|
||||
private ManualResetEvent idle;
|
||||
|
||||
private long position;
|
||||
|
||||
public long Position => position;
|
||||
public long Position { get; private set; }
|
||||
|
||||
public FileQueue( int concurrentWrites, FileCommitCallback callback ) {
|
||||
if ( concurrentWrites < 1 ) {
|
||||
|
|
@ -209,7 +205,7 @@ namespace Server {
|
|||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
position += size;
|
||||
Position += size;
|
||||
|
||||
while ( size > 0 ) {
|
||||
if ( buffered.buffer == null ) { // nothing yet buffered
|
||||
|
|
|
|||
|
|
@ -35,21 +35,18 @@ namespace Server {
|
|||
public override string Name => "Standard";
|
||||
|
||||
private Queue<Item> _decayQueue;
|
||||
private bool _permitBackgroundWrite;
|
||||
|
||||
public StandardSaveStrategy() {
|
||||
_decayQueue = new Queue<Item>();
|
||||
}
|
||||
|
||||
protected bool PermitBackgroundWrite { get => _permitBackgroundWrite;
|
||||
set => _permitBackgroundWrite = value;
|
||||
}
|
||||
protected bool PermitBackgroundWrite { get; set; }
|
||||
|
||||
protected bool UseSequentialWriters => (SaveType == SaveOption.Normal || !_permitBackgroundWrite);
|
||||
protected bool UseSequentialWriters => (SaveType == SaveOption.Normal || !PermitBackgroundWrite);
|
||||
|
||||
public override void Save(SaveMetrics metrics, bool permitBackgroundWrite)
|
||||
{
|
||||
_permitBackgroundWrite = permitBackgroundWrite;
|
||||
PermitBackgroundWrite = permitBackgroundWrite;
|
||||
|
||||
SaveMobiles(metrics);
|
||||
SaveItems(metrics);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue