Example #1
0
        /**
         * Check the the buffer capacity is the correct size (a power of 2 + {@link RingBufferDescriptor#TrailerLength}).
         *
         * @param capacity to be checked.
         * @throws IllegalStateException if the buffer capacity is incorrect.
         */

        ///<summary>
        /// Checks the buffer capacity
        /// </summary>
        public static void EnsureCapacity(IUnsafeBuffer buffer)
        {
            if ((buffer.Size - TrailerLength).IsPowerOfTwo() == false)
            {
                throw new ArgumentException("Size must be a positive power of 2 + TrailerLength, but size=" +
                                            buffer.Size);
            }
        }
Example #2
0
        public ManyToOneRingBuffer(IUnsafeBuffer buffer)
        {
            _buffer = buffer;

            EnsureCapacity(buffer);
            Capacity = buffer.Size - TrailerLength;

            _mask = Capacity - 1;
            MaximumMessageLength = Capacity / 8;
            _tail      = buffer.GetAtomicLong(Capacity + TailPositionOffset);
            _headCache = buffer.GetAtomicLong(Capacity + HeadCachePositionOffset);
            _head      = buffer.GetAtomicLong(Capacity + HeadPositionOffset);
        }
Example #3
0
        public ManyToOneRingBuffer(IUnsafeBuffer buffer)
        {
            _buffer = buffer;

            EnsureCapacity(buffer);
            Capacity = buffer.Size - TrailerLength;

            _mask = Capacity - 1;
            MaximumMessageLength = Capacity / 8;
            _tail = buffer.GetAtomicLong(Capacity + TailPositionOffset);
            _headCache = buffer.GetAtomicLong(Capacity + HeadCachePositionOffset);
            _head = buffer.GetAtomicLong(Capacity + HeadPositionOffset);
        }
Example #4
0
        public void SetUp()
        {
            _buffer = Substitute.For <IUnsafeBuffer>();
            _buffer.Size.Returns(TotalBufferLength);

            _buffer.GetAtomicLong(Arg.Any <long>()).Returns(ci => new AtomicLong((byte *)ci.Arg <long>()));
            _buffer.GetAtomicInt(Arg.Any <long>()).Returns(ci => new AtomicInt((byte *)ci.Arg <long>()));

            _atomicLong      = Substitute.For <Mocks.IAtomicLong>();
            Mocks.AtomicLong = _atomicLong;
            _atomicInt       = Substitute.For <Mocks.IAtomicInt>();
            Mocks.AtomicInt  = _atomicInt;

            _ringBuffer = new ManyToOneRingBuffer(_buffer);
        }
Example #5
0
        public void SetUp()
        {
            _buffer = Substitute.For<IUnsafeBuffer>();
            _buffer.Size.Returns(TotalBufferLength);

            _buffer.GetAtomicLong(Arg.Any<long>()).Returns(ci => new AtomicLong((byte*) ci.Arg<long>()));
            _buffer.GetAtomicInt(Arg.Any<long>()).Returns(ci => new AtomicInt((byte*) ci.Arg<long>()));

            _atomicLong = Substitute.For<Mocks.IAtomicLong>();
            Mocks.AtomicLong = _atomicLong;
            _atomicInt = Substitute.For<Mocks.IAtomicInt>();
            Mocks.AtomicInt = _atomicInt;

            _ringBuffer = new OneToOneRingBuffer(_buffer);
        }
Example #6
0
 /**
  * Check the the buffer capacity is the correct size (a power of 2 + {@link RingBufferDescriptor#TrailerLength}).
  *
  * @param capacity to be checked.
  * @throws IllegalStateException if the buffer capacity is incorrect.
  */
 ///<summary>
 /// Checks the buffer capacity
 /// </summary>
 public static void EnsureCapacity(IUnsafeBuffer buffer)
 {
     if ((buffer.Size - TrailerLength).IsPowerOfTwo() == false)
     {
         throw new ArgumentException("Size must be a positive power of 2 + TrailerLength, but size=" +
                                     buffer.Size);
     }
 }