Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PageBuffer"/> class.
        /// </summary>
        /// <param name="options">The options.</param>
        public PageBuffer(PageBufferOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.BufferType == PageBufferType.File)
            {
                tempFile = System.IO.Path.GetTempFileName();
                stream   = new FileStream(
                    System.IO.Path.GetTempFileName(),
                    FileMode.Create,
                    FileAccess.ReadWrite,
                    FileShare.None,
                    4096,
                    FileOptions.DeleteOnClose);

                if (options.EnableDoubleBuffer)
                {
                    stream = new BufferedStream(stream);
                }
            }
            else
            {
                tempFile = string.Empty;
                stream   = new MemoryStream();
                stream.SetLength(options.Capacity);
            }

            buddyAllocactor = new BuddyAllocator(stream, options.Capacity, options.MinimalCapacity);
        }
Ejemplo n.º 2
0
 public Page(BuddyAllocator allocator, Block block)
 {
     this.block     = block ?? throw new ArgumentNullException(nameof(block));
     this.allocator = allocator ?? throw new ArgumentNullException(nameof(allocator));
 }