示例#1
0
        public ByteArray Capture(int size)
        {
            size = ByteStorage.GetProperSize(size);

            lock (this) {
                var node = this.header;
                while (null != node)
                {
                    if (0 == node.RefCount && node.total >= size)
                    {
                        if (node.total >= (size << 1))
                        {
                            node.SplitByteArray(size);
                        }

                        node.Retain();
                        return(node);
                    }

                    node = node.next;
                }
            }

            return(null);
        }
示例#2
0
        public void Submit()
        {
            this.readOnly = true;
            this.position = 0;

            var size = ByteStorage.GetProperSize(this.size);

            if (this.total >= (size << 1))
            {
                SplitByteArray(size);
            }
        }
示例#3
0
 public ByteBlock(ByteStorage storage, int size)
 {
     this.storage = storage;
     this.buffer  = new byte[size];
     this.header  = new ByteArray(this, 0, size);
 }