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

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

                fileQueue.Dispose();
                fileQueue = null;

                fileStream.Close();
                fileStream = null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
		protected override void Dispose(bool disposing)
		{
			if (fileStream != null)
			{
				Flush();

				fileQueue.Dispose();
				fileQueue = null;

				fileStream.Close();
				fileStream = null;
			}

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