Exemplo n.º 1
0
        private unsafe UnmanagedDisruptor <SendRequestEntry> CreateDisruptor(IRioCompletionQueue sendingCompletionQueue, ISessionManager sessionManager)
        {
            var waitStrategy = CreateWaitStrategy();

            var disruptor = new UnmanagedDisruptor <SendRequestEntry>((IntPtr)_unmanagedRioBuffer.FirstEntry,
                                                                      _unmanagedRioBuffer.EntryReservedSpaceSize,
                                                                      _unmanagedRioBuffer.Length,
                                                                      new ThreadPerTaskScheduler(),
                                                                      ProducerType.Multi,
                                                                      waitStrategy);

            var sendRequestProcessor    = new SendRequestProcessor(_configuration, sessionManager);
            var sendCompletionProcessor = new SendCompletionProcessor(_configuration, sendingCompletionQueue);

            disruptor.HandleEventsWith(sendRequestProcessor).Then(sendCompletionProcessor);

            ConfigureWaitStrategy(waitStrategy, disruptor, sendCompletionProcessor);

            return(disruptor);
        }
Exemplo n.º 2
0
 private static void ConfigureWaitStrategy(IWaitStrategy waitStrategy, UnmanagedDisruptor <SendRequestEntry> disruptor, SendCompletionProcessor sendCompletionProcessor)
 {
     switch (waitStrategy)
     {
     case HybridWaitStrategy hybridWaitStrategy:
         hybridWaitStrategy.SequenceBarrierForSendCompletionProcessor = disruptor.GetBarrierFor(sendCompletionProcessor);
         return;
     }
 }