protected static CompositeByteBuffer ToLeakAwareBuffer(CompositeByteBuffer buf)
        {
            IResourceLeakTracker leak;

            switch (ResourceLeakDetector.Level)
            {
            case ResourceLeakDetector.DetectionLevel.Simple:
                leak = AbstractByteBuffer.LeakDetector.Track(buf);
                if (leak != null)
                {
                    buf = new SimpleLeakAwareCompositeByteBuffer(buf, leak);
                }
                break;

            case ResourceLeakDetector.DetectionLevel.Advanced:
            case ResourceLeakDetector.DetectionLevel.Paranoid:
                leak = AbstractByteBuffer.LeakDetector.Track(buf);
                if (leak != null)
                {
                    buf = new AdvancedLeakAwareCompositeByteBuffer(buf, leak);
                }
                break;

            case ResourceLeakDetector.DetectionLevel.Disabled:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(buf);
        }
Exemplo n.º 2
0
 internal SimpleLeakAwareCompositeByteBuffer(CompositeByteBuffer wrapped, IResourceLeakTracker leak) : base(wrapped)
 {
     if (leak is null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.leak);
     }
     Leak = leak;
 }
Exemplo n.º 3
0
        public static ReadableBuffer Composite(IEnumerable <ReadableBuffer> buffers)
        {
            if (buffers is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.buffers);
            }

            CompositeByteBuffer composite = Unpooled.CompositeBuffer();

            foreach (ReadableBuffer buf in buffers)
            {
                IByteBuffer byteBuffer = buf._buffer;
                if (byteBuffer.IsReadable())
                {
                    composite.AddComponent(byteBuffer);
                }
            }

            return(new ReadableBuffer(composite));
        }
Exemplo n.º 4
0
 internal WrappedCompositeByteBuffer(CompositeByteBuffer wrapped) : base(wrapped.Allocator)
 {
     this.wrapped = wrapped;
     this.SetMaxCapacity(this.wrapped.MaxCapacity);
 }
Exemplo n.º 5
0
        public override CompositeByteBuffer CompositeDirectBuffer(int maxNumComponents)
        {
            var buf = new CompositeByteBuffer(this, true, maxNumComponents);

            return(this.disableLeakDetector ? buf : ToLeakAwareBuffer(buf));
        }
        public override CompositeByteBuffer CompositeHeapBuffer(int maxNumComponents)
        {
            var buf = new CompositeByteBuffer(this, false, maxNumComponents);

            return(_disableLeakDetector ? buf : ToLeakAwareBuffer(buf));
        }
 internal AdvancedLeakAwareCompositeByteBuffer(CompositeByteBuffer wrapped, IResourceLeakTracker leak)
     : base(wrapped, leak)
 {
 }
Exemplo n.º 8
0
 internal SimpleLeakAwareCompositeByteBuffer(CompositeByteBuffer wrapped, IResourceLeakTracker leak) : base(wrapped)
 {
     Contract.Requires(leak != null);
     this.Leak = leak;
 }