/// <summary>
        /// 
        /// </summary>
        public ByteRingBuffer(CancellationToken cancellationToken, int bufferSize, WaitingStrategy waitingStrategy)
            : base(cancellationToken, bufferSize, waitingStrategy)
        {
            if (bufferSize < MinBufferSize) throw new ArgumentException("buffer must be at least " + MinBufferSize, "bufferSize");

            _buffer = new byte[bufferSize];
        }
        private volatile int _gateState = 0; // 11111111 11111111 11111111 11111111

        #endregion Fields

        #region Constructors

        protected BaseRingBuffer(CancellationToken cancellationToken, int bufferSize, WaitingStrategy waitingStrategy)
        {
            if (bufferSize <= 0) throw new ArgumentOutOfRangeException("bufferSize");
            if (!Utils.IsPowerOfTwo(bufferSize)) throw new ArgumentException("bufferSize must be multiple of 2", "bufferSize");

            _cancellationToken = cancellationToken;
            _waitingStrategy = waitingStrategy;
            _bufferSize = (uint)bufferSize;
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        public ByteRingBuffer(CancellationToken cancellationToken, int bufferSize, WaitingStrategy waitingStrategy)
            : base(cancellationToken, bufferSize, waitingStrategy)
        {
            if (bufferSize < MinBufferSize)
            {
                throw new ArgumentException("buffer must be at least " + MinBufferSize, "bufferSize");
            }

            _buffer = new byte[bufferSize];
        }
Beispiel #4
0
        protected BaseRingBuffer(CancellationToken cancellationToken, int bufferSize, WaitingStrategy waitingStrategy)
        {
            if (bufferSize <= 0)
            {
                throw new ArgumentOutOfRangeException("bufferSize");
            }
            if (!Utils.IsPowerOfTwo(bufferSize))
            {
                throw new ArgumentException("bufferSize must be multiple of 2", "bufferSize");
            }

            _cancellationToken = cancellationToken;
            _waitingStrategy   = waitingStrategy;
            _bufferSize        = (uint)bufferSize;
        }