Exemplo n.º 1
0
        private uint Complete()
        {
            // Reserve a submission to prepare operations on the eventFd later on
            var  eventFdSubmissionAvailable = _ring.TryGetSubmissionQueueEntryUnsafe(out var eventFdSubmission);
            uint skip = 1;

            foreach (var completion in _ring.Completions)
            {
                var(result, userData)      = completion;
                var(socket, operationType) = AsyncOperation.FromUlong(userData);
                if ((operationType & OperationType.EventFdOperation) == 0)
                {
                    // hot path
                    Complete(socket, operationType, result);
                }
                else
                {
                    if (!eventFdSubmissionAvailable)
                    {
                        ThrowHelper.ThrowNewSubmissionQueueFullException();
                    }
                    if (operationType == OperationType.EventFdReadPoll)
                    {
                        _unblockHandle.CompleteEventFdReadPoll(eventFdSubmission, result);
                    }
                    else
                    {
                        _unblockHandle.CompleteEventFdRead(eventFdSubmission, result);
                    }

                    skip = 0; // Don't skip eventFd submission, now that we used it
                }
            }

            return(skip);
        }