예제 #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);
 }