Represents an efficiently allocated buffer for asynchronous read/write operations.
Inheritance: IBuffer
        /// <summary>
        /// Helper method that gets a filled buffer constructed from a list of memory blocks
        /// </summary>
        /// <param name="allocatedBlocks">The memoryblocks that comprise the buffer</param>
        /// <param name="filledWith">If not null, the contents the memory block will be filled with</param>
        /// <returns>An optionally filled IBuffer object</returns>
        private static IBuffer GetFilledBuffer(IList <IMemoryBlock> allocatedBlocks, byte[] filledWith)
        {
            IBuffer newBuffer = new ManagedBuffer(allocatedBlocks);

            if (filledWith != null)
            {
                newBuffer.FillWith(filledWith);
            }
            return(newBuffer);
        }
Beispiel #2
0
 public void BufferConstructorTest()
 {
     IMemoryBlock nullSlab = null;
     ManagedBuffer target = new ManagedBuffer(nullSlab);
 }
Beispiel #3
0
        private static ManagedBuffer GetNewBuffer(IMemorySlab Slab)
        {
            IMemoryBlock allocatedMemoryBlock;
            Slab.TryAllocate(blockSize, out allocatedMemoryBlock);

            ManagedBuffer target = new ManagedBuffer(allocatedMemoryBlock);
            return target;
        }
 /// <summary>
 /// Helper method that gets a filled buffer constructed from a list of memory blocks
 /// </summary>
 /// <param name="allocatedBlocks">The memoryblocks that comprise the buffer</param>
 /// <param name="filledWith">If not null, the contents the memory block will be filled with</param>
 /// <returns>An optionally filled IBuffer object</returns>
 private static IBuffer GetFilledBuffer(IList<IMemoryBlock> allocatedBlocks, byte[] filledWith)
 {
     IBuffer newBuffer = new ManagedBuffer(allocatedBlocks);
     if (filledWith != null) newBuffer.FillWith(filledWith);
     return newBuffer;
 }
Beispiel #5
0
        //Gets a multi slab buffer
        private static ManagedBuffer GetNewBuffer(IMemorySlab[] Slabs)
        {
            List<IMemoryBlock> blockList = new List<IMemoryBlock>();
            IMemoryBlock allocatedMemoryBlock;

            foreach (var slab in Slabs)
            {
                slab.TryAllocate(blockSize, out allocatedMemoryBlock);
                blockList.Add(allocatedMemoryBlock);
            }

            ManagedBuffer target = new ManagedBuffer(blockList);
            return target;
        }
Beispiel #6
0
 public void BufferConstructorTest2()
 {
     IMemoryBlock[] emptyBlocks = new IMemoryBlock[0];
     ManagedBuffer target = new ManagedBuffer(emptyBlocks);
 }
Beispiel #7
0
 public void BufferConstructorTest()
 {
     IMemoryBlock[] nullBlocks = null;
     ManagedBuffer target = new ManagedBuffer(nullBlocks);
 }