Coordinator for claiming sequences for access to a data structure while tracking dependent Sequences. Suitable for use for sequencing across multiple publisher threads.

Note on Sequencer.Cursor: With this sequencer the cursor value is updated after the call to Sequencer.Next(), to determine the highest available sequence that can be read, then GetHighestPublishedSequence should be used.
Inheritance: Disruptor.Sequencer
示例#1
0
        // padding: 7

        public SequencerDispatcher(ISequencer sequencer)
        {
            _singleProducerSequencer = default;
            _multiProducerSequencer  = default;
            _type = sequencer switch
            {
                SingleProducerSequencer _ => SequencerType.SingleProducer,
                MultiProducerSequencer _ => SequencerType.MultiProducer,
                                        _ => SequencerType.Unknown,
            };

            Sequencer = sequencer;
        }
示例#2
0
        /// <summary>
        ///     Create a new multiple producer RingBuffer using the default wait strategy  <see cref="BlockingWaitStrategy" />.
        /// </summary>
        /// <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>
        public static RingBuffer <T> CreateMultiProducer(Func <T> factory, int bufferSize, IWaitStrategy waitStrategy)
        {
            MultiProducerSequencer sequencer = new MultiProducerSequencer(bufferSize, waitStrategy);

            return(new RingBuffer <T>(factory, sequencer));
        }