コード例 #1
0
        /// <summary>
        /// Create a new sequencer with the specified producer type.
        /// </summary>
        /// <param name="producerType">producer type to use <see cref="ProducerType" /></param>
        /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
        /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
        /// <returns>a constructed ring buffer.</returns>
        /// <exception cref="ArgumentOutOfRangeException">if the producer type is invalid</exception>
        /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
        public static ISequencer Create(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.Single:
                return(new SingleProducerSequencer(bufferSize, waitStrategy));

            case ProducerType.Multi:
                return(new MultiProducerSequencer(bufferSize, waitStrategy));

            default:
                throw new ArgumentOutOfRangeException(producerType.ToString());
            }
        }
コード例 #2
0
ファイル: RingBuffer.cs プロジェクト: zzms/Disruptor-net
        /// <summary>
        ///     Create a new Ring Buffer with the specified producer type (SINGLE or MULTI)
        /// </summary>
        /// <param name="producerType">producer type to use <see cref="ProducerType" /></param>
        /// <param name="factory">used to create the events within the ring buffer.</param>
        /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
        /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static RingBuffer <T> Create(ProducerType producerType, Func <T> factory, int bufferSize, IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.Single:
                return(CreateSingleProducer(factory, bufferSize, waitStrategy));

            case ProducerType.Multi:
                return(CreateMultiProducer(factory, bufferSize, waitStrategy));

            default:
                throw new ArgumentOutOfRangeException(producerType.ToString());
            }
        }
コード例 #3
0
        private ISequencer newProducer(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.SINGLE:
                return(new SingleProducerSequencer(bufferSize, waitStrategy));

            case ProducerType.MULTI:
                return(new MultiProducerSequencer(bufferSize, waitStrategy));

            default:
                throw new ArgumentException(producerType.ToString());
            }
        }
コード例 #4
0
ファイル: RingBuffer.cs プロジェクト: lichunhui811217/MDA
        /// <summary>
        /// Create a new Ring Buffer with the specified producer type (SINGLE or MULTI).
        /// </summary>
        /// <param name="producerType">producer type to use <see cref="ProducerType"/>.</param>
        /// <param name="factory">used to create events within the ring buffer.</param>
        /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
        /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
        /// <returns>a constructed ring buffer.</returns>
        /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
        public static RingBuffer <TEvent> Create(
            ProducerType producerType,
            IEventFactory <TEvent> factory,
            int bufferSize,
            IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.Single:
                return(CreateSingleProducer(factory, bufferSize, waitStrategy));

            case ProducerType.Multi:
                return(CreateMultiProducer(factory, bufferSize, waitStrategy));

            default:
                throw new IllegalStateException(producerType.ToString());
            }
        }
コード例 #5
0
 private ISequencer newProducer(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
 {
     switch (producerType)
     {
         case ProducerType.SINGLE:
             return new SingleProducerSequencer(bufferSize, waitStrategy);
         case ProducerType.MULTI:
             return new MultiProducerSequencer(bufferSize, waitStrategy);
         default:
             throw new ArgumentException(producerType.ToString());
     }
 }