public MultiProducerSequencerRef2(int bufferSize, IWaitStrategy waitStrategy) { 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"); } _bufferSize = bufferSize; _waitStrategy = waitStrategy; _isBlockingWaitStrategy = !(waitStrategy is INonBlockingWaitStrategy); #if NETCOREAPP _availableBuffer = GC.AllocateArray <int>(bufferSize, pinned: true); _availableBufferPointer = (int *)Unsafe.AsPointer(ref _availableBuffer[0]); #else _availableBuffer = new int[bufferSize]; #endif _indexMask = bufferSize - 1; _indexShift = DisruptorUtil.Log2(bufferSize); InitialiseAvailableBuffer(); }
public MultiProducerSequencerRef1(int bufferSize, IWaitStrategy waitStrategy) { 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"); } _bufferSize = bufferSize; _waitStrategy = waitStrategy; _isBlockingWaitStrategy = !(waitStrategy is INonBlockingWaitStrategy); _availableBuffer = new int[bufferSize]; _indexMask = bufferSize - 1; _indexShift = DisruptorUtil.Log2(bufferSize); InitialiseAvailableBuffer(); }