Пример #1
0
        public BufSlice Capture(int size)
        {
            size = BufStorage.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 = BufStorage.GetProperSize(this.Size);

            if (this.Total >= (size << 1))
            {
                SplitByteArray(size);
            }
        }
Пример #3
0
 public BufBlock(BufStorage storage, int size)
 {
     this.Storage = storage;
     this.Buffer  = new byte[size];
     this.header  = new BufSlice(this, 0, size);
 }