Inheritance: IDisposable
コード例 #1
0
ファイル: FileQueue.cs プロジェクト: greeduomacro/last-wish
			public Chunk( FileQueue owner, int slot, byte[] buffer, int offset, int size ) {
				this.owner = owner;
				this.slot = slot;

				this.buffer = buffer;
				this.offset = offset;
				this.size = size;
			}
コード例 #2
0
            public Chunk(FileQueue owner, int slot, byte[] buffer, int offset, int size)
            {
                this.owner = owner;
                this.slot  = slot;

                this.buffer = buffer;
                this.offset = offset;
                this.size   = size;
            }
コード例 #3
0
            public Chunk(FileQueue _owner, int _slot, byte[] _buffer, int _offset, int _size)
            {
                owner = _owner;
                slot  = _slot;

                buffer = _buffer;
                offset = _offset;
                size   = _size;
            }
コード例 #4
0
        public SequentialFileWriter(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);

            fileQueue = new FileQueue(Math.Max(1, FileOperations.Concurrency), FileCallback);
        }
コード例 #5
0
		public SequentialFileWriter(string path, SaveMetrics metrics)
		{
			if (path == null)
			{
				throw new ArgumentNullException("path");
			}

			this.metrics = metrics;

			fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);

			fileQueue = new FileQueue(Math.Max(1, FileOperations.Concurrency), FileCallback);
		}
コード例 #6
0
        protected override void Dispose(bool disposing)
        {
            if (fileStream != null)
            {
                Flush();

                fileQueue.Dispose();
                fileQueue = null;

                fileStream.Close();
                fileStream = null;
            }

            base.Dispose(disposing);
        }
コード例 #7
0
        public SequentialFileWriter(string path, SaveMetrics metrics)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            this.metrics = metrics;

            this.fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);

            this.fileQueue = new FileQueue(
                Math.Max(1, FileOperations.Concurrency),
                FileCallback);
        }
コード例 #8
0
		protected override void Dispose(bool disposing)
		{
			if (fileStream != null)
			{
				Flush();

				fileQueue.Dispose();
				fileQueue = null;

				fileStream.Close();
				fileStream = null;
			}

			base.Dispose(disposing);
		}
コード例 #9
0
		private void FileCallback( FileQueue.Chunk chunk ) {
			if ( FileOperations.AreSynchronous ) {
				fileStream.Write( chunk.Buffer, chunk.Offset, chunk.Size );

				if ( metrics != null ) {
					metrics.OnFileWritten( chunk.Size );
				}

				chunk.Commit();
			} else {
				if ( writeCallback == null ) {
					writeCallback = this.OnWrite;
				}

				fileStream.BeginWrite( chunk.Buffer, chunk.Offset, chunk.Size, writeCallback, chunk );
			}
		}