Exemplo n.º 1
0
        public Ring(int entries, RingOptions?ringOptions = default)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                throw new PlatformNotSupportedException();
            }
            if (entries < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(entries), "must be non-zero positive value");
            }

            io_uring_params p  = default;
            int             fd = Setup((uint)entries, &p, ringOptions);

            _ringFd = new CloseHandle();
            _ringFd.SetHandle(fd);

            _flags    = p.flags;
            _features = p.features;

            var(sqSize, cqSize) = GetSize(&p);

            try
            {
                _sq = MapSq(fd, sqSize, &p, out _sqHandle, out _sqeHandle);
                _cq = MapCq(fd, cqSize, &p, _sqHandle, out _cqHandle);
            }
            catch (ErrnoException)
            {
                // Ensure we don't leak file handles on error
                Dispose();
                throw;
            }

            SubmissionQueueSize = (int)sqSize;
            CompletionQueueSize = (int)cqSize;
        }
Exemplo n.º 2
0
        Ring(int entries, object?hack, RingOptions? ringOptions = default)
#endif
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || !KernelVersion.Supports.IoUring)
            {
                ThrowPlatformNotSupportedException();
            }
            if (entries < 1)
            {
                ThrowArgumentOutOfRangeException(ExceptionArgument.entries);
            }

            io_uring_params p  = default;
            int             fd = Setup((uint)entries, &p, ringOptions);

            _ringFd = new CloseHandle();
            _ringFd.SetHandle(fd);

            _flags    = p.flags;
            _features = p.features;

            var(sqSize, cqSize) = GetSize(&p);

            try
            {
                _sq = MapSq(fd, sqSize, &p, SubmissionPollingEnabled, IoPollingEnabled, out _sqHandle, out _sqeHandle);
                _cq = MapCq(fd, cqSize, &p, _sqHandle, IoPollingEnabled, out _cqHandle);
                _supportedOperations = FetchSupportedOperations(fd);
            }
            catch (ErrnoException)
            {
                // Ensure we don't leak file handles on error
                Dispose();
                throw;
            }
        }