/// <summary> /// Create a new UnmanagedDisruptor. Will default to <see cref="BlockingWaitStrategy"/> and <see cref="ProducerType.Multi"/>. /// </summary> /// <param name="pointer">pointer to the first event of the buffer</param> /// <param name="eventSize">size of each event</param> /// <param name="ringBufferSize">the number of events of the ring buffer, must be power of 2</param> /// <param name="taskScheduler">a <see cref="TaskScheduler"/> to create threads for processors</param> public UnmanagedDisruptor(IntPtr pointer, int eventSize, int ringBufferSize, TaskScheduler taskScheduler) : this(new UnmanagedRingBuffer <T>(pointer, eventSize, SequencerFactory.Create(ProducerType.Multi, ringBufferSize)), taskScheduler) { }
/// <summary> /// Create a new UnmanagedDisruptor. /// </summary> /// <param name="pointer">pointer to the first event of the buffer</param> /// <param name="eventSize">size of each event</param> /// <param name="ringBufferSize">the number of events of the ring buffer, must be power of 2</param> /// <param name="taskScheduler">a <see cref="TaskScheduler"/> to create threads for processors</param> /// <param name="producerType">the claim strategy to use for the ring buffer</param> /// <param name="waitStrategy">the wait strategy to use for the ring buffer</param> public UnmanagedDisruptor(IntPtr pointer, int eventSize, int ringBufferSize, TaskScheduler taskScheduler, ProducerType producerType, IWaitStrategy waitStrategy) : this(new UnmanagedRingBuffer <T>(pointer, eventSize, SequencerFactory.Create(producerType, ringBufferSize, waitStrategy)), taskScheduler) { }
public MultiProducerSequencer(int bufferSize) : this(bufferSize, SequencerFactory.DefaultWaitStrategy()) { }
/// <summary> /// Construct an UnmanagedRingBuffer with the full option set. /// The <see cref="UnmanagedRingBufferMemory"/> is not owned by the ring buffer and should be disposed after shutdown. /// </summary> /// <param name="memory">block of memory that will store the events</param> /// <param name="producerType">producer type to use <see cref="ProducerType" /></param> /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param> /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception> public UnmanagedRingBuffer(UnmanagedRingBufferMemory memory, ProducerType producerType, IWaitStrategy waitStrategy) : base(SequencerFactory.Create(producerType, memory.EventCount, waitStrategy), memory.PointerToFirstEvent, memory.EventSize) { }
/// <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> /// <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 <T> CreateMultiProducer(Func <T> factory, int bufferSize) { return(CreateMultiProducer(factory, bufferSize, SequencerFactory.DefaultWaitStrategy())); }
private static IValueRingBuffer <StubValueEvent> CreateRingBuffer(int size, ProducerType producerType) { return(new ValueRingBuffer <StubValueEvent>(() => new StubValueEvent(-1), SequencerFactory.Create(producerType, size))); }
/// <summary> /// Create a new ValueDisruptor. /// </summary> /// <param name="eventFactory">the factory to create events in the ring buffer</param> /// <param name="ringBufferSize">the size of the ring buffer, must be power of 2</param> /// <param name="taskScheduler">a <see cref="TaskScheduler"/> to create threads for processors</param> /// <param name="producerType">the claim strategy to use for the ring buffer</param> /// <param name="waitStrategy">the wait strategy to use for the ring buffer</param> public ValueDisruptor(Func <T> eventFactory, int ringBufferSize, TaskScheduler taskScheduler, ProducerType producerType, IWaitStrategy waitStrategy) : this(new ValueRingBuffer <T>(eventFactory, SequencerFactory.Create(producerType, ringBufferSize, waitStrategy)), taskScheduler) { }