public CompositeByteBuffer(IByteBufferAllocator allocator, int maxNumComponents)
            : base(int.MaxValue)
        {
            Contract.Requires(allocator != null);
            Contract.Requires(maxNumComponents >= 2);

            this.allocator        = allocator;
            this.maxNumComponents = maxNumComponents;
            this.leak             = LeakDetector.Open(this);
        }
Beispiel #2
0
        public CompositeByteBuffer(IByteBufferAllocator allocator, int maxNumComponents)
            : base(AbstractByteBufferAllocator.DefaultMaxCapacity)
        {
            Contract.Requires(allocator != null);
            Contract.Requires(maxNumComponents >= 2);

            this.allocator        = allocator;
            this.maxNumComponents = maxNumComponents;
            this.leak             = LeakDetector.Open(this);
        }
Beispiel #3
0
        public CompositeByteBuffer(IByteBufferAllocator allocator, int maxNumComponents, IByteBuffer[] buffers, int offset, int length)
            : base(AbstractByteBufferAllocator.DefaultMaxCapacity)
        {
            Contract.Requires(allocator != null);
            Contract.Requires(maxNumComponents >= 2);

            this.allocator        = allocator;
            this.maxNumComponents = maxNumComponents;
            this.AddComponents0(0, buffers, offset, length);
            this.ConsolidateIfNeeded();
            this.SetIndex(0, this.Capacity);
            this.leak = LeakDetector.Open(this);
        }
        public CompositeByteBuffer(
            IByteBufferAllocator allocator, int maxNumComponents, IEnumerable <IByteBuffer> buffers)
            : base(int.MaxValue)
        {
            Contract.Requires(allocator != null);
            Contract.Requires(maxNumComponents >= 2);

            this.allocator        = allocator;
            this.maxNumComponents = maxNumComponents;
            this.AddComponents0(0, buffers);
            this.ConsolidateIfNeeded();
            this.SetIndex(0, this.Capacity);
            this.leak = LeakDetector.Open(this);
        }
        public void LeakDetectorScenario(SocketScenario scenario)
        {
            var leakDetector = new LeakDetector(scenario.Settings);

            foreach (var i in scenario.SocketCounts)
            {
                leakDetector.Next(i);
                _helper.WriteLine("ports: {0}, Observed % Diff: {1}, Fail? {2}", i,
                                  leakDetector.RelativeDifference, leakDetector.ShouldFail);
                if (!scenario.ShouldFail) // if we can't fail in this scenario, no intermittent failures allowed
                {
                    scenario.ShouldFail.Should().BeFalse();
                }
            }

            leakDetector.ShouldFail.Should().Be(scenario.ShouldFail,
                                                "Failure state should have been {0}, but was {1} in scenario {2}. Final % difference: {3} vs. target of {4}",
                                                scenario.ShouldFail,
                                                leakDetector.ShouldFail, scenario, leakDetector.RelativeDifference, scenario.Settings.MaxDifference);
        }