Inheritance: IDisposable
Exemple #1
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;
			}
Exemple #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;
            }
Exemple #3
0
            public Chunk(FileQueue _owner, int _slot, byte[] _buffer, int _offset, int _size)
            {
                owner = _owner;
                slot  = _slot;

                buffer = _buffer;
                offset = _offset;
                size   = _size;
            }
        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);
        }
		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);
		}
        protected override void Dispose(bool disposing)
        {
            if (fileStream != null)
            {
                Flush();

                fileQueue.Dispose();
                fileQueue = null;

                fileStream.Close();
                fileStream = null;
            }

            base.Dispose(disposing);
        }
Exemple #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);
        }
		protected override void Dispose(bool disposing)
		{
			if (fileStream != null)
			{
				Flush();

				fileQueue.Dispose();
				fileQueue = null;

				fileStream.Close();
				fileStream = null;
			}

			base.Dispose(disposing);
		}
		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 );
			}
		}