Exemplo n.º 1
0
        public void Receive(Ring ring)
        {
            // Start work-around for https://github.com/axboe/liburing/issues/128
            /*
            _iov.AsSpan().Clear();
            _dummyBuffer.AsSpan().Clear();
            _control.AsSpan().Clear();
            _header.AsSpan().Clear();

            iovec* iov = (iovec*) MemoryHelper.UnsafeGetAddressOfPinnedArrayData(_iov);
            iov->iov_base = (byte*) MemoryHelper.UnsafeGetAddressOfPinnedArrayData(_dummyBuffer);
            iov->iov_len = 1;

            byte* control = (byte*) MemoryHelper.UnsafeGetAddressOfPinnedArrayData(_control);

            msghdr* header = (msghdr*) MemoryHelper.UnsafeGetAddressOfPinnedArrayData(_header);
            header->msg_iov = iov;
            header->msg_iovlen = 1;
            header->msg_control = control;
            header->msg_controllen = _control.Length;

            int socket = _recipient;
            ring.PrepareRecvMsg(socket, header, (uint)(MSG_NOSIGNAL | MSG_CMSG_CLOEXEC), AsyncOperation.RecvSocket(socket).AsUlong());
            */
            if (!ring.TryPrepareNop(AsyncOperation.RecvSocket(_recipient).AsUlong()))
            {
                _scheduler.ScheduleRecvSocket(_recipient);
            }
            // End work-around for https://github.com/axboe/liburing/issues/128
        }
 public void ScheduleRecvSocket(int socket)
 {
     _asyncOperationQueue.Enqueue(AsyncOperation.RecvSocket(socket));
 }