Exemplo n.º 1
0
    protected SequencerDispatcher _sequencerDispatcher; // includes 7 bytes of padding

    // padding: DefaultPadding

    /// <summary>
    /// Construct a RingBuffer with the full option set.
    /// </summary>
    /// <param name="sequencer">sequencer to handle the ordering of events moving through the RingBuffer.</param>
    /// <param name="eventType">type of ring buffer events</param>
    /// <param name="bufferPad">ring buffer padding  as a number of events</param>
    /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
    protected RingBuffer(ISequencer sequencer, Type eventType, int bufferPad)
    {
        _sequencerDispatcher = new SequencerDispatcher(sequencer);
        _bufferSize          = sequencer.BufferSize;

        if (_bufferSize < 1)
        {
            throw new ArgumentException("bufferSize must not be less than 1");
        }
        if (!_bufferSize.IsPowerOf2())
        {
            throw new ArgumentException("bufferSize must be a power of 2");
        }

        _entries   = Array.CreateInstance(eventType, _bufferSize + 2 * bufferPad);
        _indexMask = _bufferSize - 1;
    }
Exemplo n.º 2
0
    protected SequencerDispatcher _sequencerDispatcher; // includes 7 bytes of padding

    // padding: DefaultPadding

    /// <summary>
    /// Construct a UnmanagedRingBuffer with the full option set.
    /// </summary>
    /// <param name="sequencer">sequencer to handle the ordering of events moving through the UnmanagedRingBuffer.</param>
    /// <param name="pointer">pointer to the first element of the buffer</param>
    /// <param name="eventSize">size of each event</param>
    /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
    protected UnmanagedRingBuffer(ISequencer sequencer, IntPtr pointer, int eventSize)
    {
        if (eventSize < 1)
        {
            throw new ArgumentException("eventSize must not be less than 1");
        }
        if (sequencer.BufferSize < 1)
        {
            throw new ArgumentException("bufferSize must not be less than 1");
        }
        if (!sequencer.BufferSize.IsPowerOf2())
        {
            throw new ArgumentException("bufferSize must be a power of 2");
        }

        _sequencerDispatcher = new SequencerDispatcher(sequencer);
        _bufferSize          = sequencer.BufferSize;
        _entries             = pointer;
        _indexMask           = _bufferSize - 1;
        _eventSize           = eventSize;
    }
 public SequencerDispatcherBenchmarks_SingleProducer()
 {
     _singleProducerSequencer = new SingleProducerSequencer(1024, new YieldingWaitStrategy());
     _sequencer  = _singleProducerSequencer;
     _dispatcher = new SequencerDispatcher(_sequencer);
 }
 public SequencerDispatcherBenchmarks()
 {
     _sequencer  = new SingleProducerSequencer(1024);
     _dispatcher = new SequencerDispatcher(_sequencer);
 }