Esempio n. 1
0
 internal RioCompletionWorker(int workerId, IWorkerConfiguration configuration, ICompletionHandler completionHandler)
 {
     _workerId              = workerId;
     _configuration         = configuration;
     _completionHandler     = completionHandler;
     SendingCompletionQueue = new RioCompletionQueue(configuration.CompletionQueueSize);
 }
 public ReceiveCompletionProcessor(ZerioConfiguration configuration, RioCompletionQueue receivingCompletionQueue, ISessionManager sessionManager, RequestProcessingEngine requestProcessingEngine)
 {
     _configuration            = configuration;
     _receivingCompletionQueue = receivingCompletionQueue;
     _sessionManager           = sessionManager;
     _requestProcessingEngine  = requestProcessingEngine;
 }
Esempio n. 3
0
 public SendCompletionProcessor(ZerioConfiguration configuration, RioCompletionQueue sendCompletionQueue)
 {
     _configuration            = configuration;
     _sendCompletionQueue      = sendCompletionQueue;
     _completionResults        = new RIO_RESULT[configuration.MaxSendCompletionResults];
     _completionResultsHandle  = GCHandle.Alloc(_completionResults, GCHandleType.Pinned);
     _completionResultsPointer = (RIO_RESULT *)_completionResultsHandle.AddrOfPinnedObject().ToPointer();
 }
Esempio n. 4
0
        public static RioRequestQueue Create(int correlationId, IntPtr socket, RioCompletionQueue sendingCompletionQueue, uint maxOutstandingSends, RioCompletionQueue receivingCompletionQueue, uint maxOutstandingReceives)
        {
            var requestQueue = WinSock.Extensions.CreateRequestQueue(socket, maxOutstandingReceives, 1, maxOutstandingSends, 1, receivingCompletionQueue.QueueHandle, sendingCompletionQueue.QueueHandle, correlationId);

            if (requestQueue == IntPtr.Zero)
            {
                WinSock.ThrowLastWsaError();
            }

            return(new RioRequestQueue(requestQueue));
        }
Esempio n. 5
0
        public RequestProcessingEngine(ZerioConfiguration configuration, RioCompletionQueue sendingCompletionQueue, ISessionManager sessionManager)
        {
            _configuration = configuration;

            var ringBufferSize = ZerioConfiguration.GetNextPowerOfTwo(_configuration.SendingBufferCount + _configuration.ReceivingBufferCount * _configuration.SessionCount);

            _unmanagedRioBuffer = new UnmanagedRioBuffer <RequestEntry>(ringBufferSize, _configuration.SendingBufferLength);

            _disruptor  = CreateDisruptor(sendingCompletionQueue, sessionManager);
            _ringBuffer = _disruptor.RingBuffer;
        }
Esempio n. 6
0
        public RioSession(int sessionId, ISessionConfiguration configuration, RioCompletionQueue sendingCompletionQueue, RioCompletionQueue receivingCompletionQueue, SerializationEngine serializationEngine)
        {
            Id             = sessionId;
            _configuration = configuration;

            _sendingCompletionQueue   = sendingCompletionQueue;
            _receivingCompletionQueue = receivingCompletionQueue;

            _sendingBufferManager   = RioBufferManager.Allocate(configuration.SendingBufferCount, _configuration.SendingBufferLength);
            _receivingBufferManager = RioBufferManager.Allocate(configuration.ReceivingBufferCount, _configuration.ReceivingBufferLength);

            _messageFramer = new MessageFramer(_receivingBufferManager);

            _threadLocalReceivingContext = new ThreadLocal <ReceivingContext>(() => new ReceivingContext(serializationEngine.Encoding));
            _threadLocalSendingContext   = new ThreadLocal <SendingContext>(() => new SendingContext(configuration, _sendingBufferManager, serializationEngine.Encoding));

            _serializationEngine = serializationEngine;
        }
Esempio n. 7
0
        private unsafe UnmanagedDisruptor <RequestEntry> CreateDisruptor(RioCompletionQueue sendingCompletionQueue, ISessionManager sessionManager)
        {
            var waitStrategy = CreatWaitStrategy();

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

            var requestProcessor        = new RequestProcessor(_configuration, sessionManager);
            var sendCompletionProcessor = new SendCompletionProcessor(_configuration, sendingCompletionQueue);

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

            ConfigureWaitStrategy(waitStrategy, disruptor, sendCompletionProcessor);

            return(disruptor);
        }
Esempio n. 8
0
 public CompletionQueues(ZerioConfiguration configuration)
 {
     SendingQueue   = new RioCompletionQueue((configuration.MaxSendCompletionResults + configuration.MaxReceiveCompletionResults) * configuration.SessionCount);
     ReceivingQueue = new RioCompletionQueue((configuration.MaxSendCompletionResults + configuration.MaxReceiveCompletionResults) * configuration.SessionCount);
 }
Esempio n. 9
0
 public CompletionQueues(InternalZerioConfiguration configuration)
 {
     SendingQueue   = new RioCompletionQueue(configuration.SendingCompletionQueueSize);
     ReceivingQueue = new RioCompletionQueue(configuration.ReceivingCompletionQueueSize);
 }