Пример #1
0
            public IOUringAsyncContext(IOUringThread thread, SafeHandle handle)
            {
                _iouring    = thread;
                _writeQueue = new Queue(thread, this, readNotWrite: false);
                _readQueue  = new Queue(thread, this, readNotWrite: true);
                bool success = false;

                handle.DangerousAddRef(ref success);
                _fd     = handle.DangerousGetHandle().ToInt32();
                _handle = handle;
                SocketPal.SetNonBlocking(handle);
            }
            public EPollAsyncContext(EPollThread thread, SafeHandle handle)
            {
                _epoll      = thread;
                _writeQueue = new Queue(thread);
                _readQueue  = new Queue(thread);
                bool success = false;

                handle.DangerousAddRef(ref success);
                _fd     = handle.DangerousGetHandle().ToInt32();
                _handle = handle;

                SocketPal.SetNonBlocking(handle);
                _epoll.Control(EPOLL_CTL_ADD, _fd, EPOLLIN | EPOLLOUT | EPOLLET, Key);
            }
            private void EnsureNonBlocking()
            {
                SafeHandle?handle = _handle;

                if (handle == null)
                {
                    // We've been disposed.
                    return;
                }

                if (!_setToNonBlocking)
                {
                    SocketPal.SetNonBlocking(handle);
                    _setToNonBlocking = true;
                }
            }