Home / Class/ DefaultIoUringIoRegistration Class — netty Architecture

DefaultIoUringIoRegistration Class — netty Architecture

Architecture documentation for the DefaultIoUringIoRegistration class in IoUringIoHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d80a868d_a459_8e74_141b_ceb61647050d["DefaultIoUringIoRegistration"]
  b567715e_8085_11b5_5111_a83c7d3cb07a["IoUringIoHandler.java"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|defined in| b567715e_8085_11b5_5111_a83c7d3cb07a
  7b7c68d9_7d0a_54b0_a9b7_25aaf2764a02["DefaultIoUringIoRegistration()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 7b7c68d9_7d0a_54b0_a9b7_25aaf2764a02
  3165a179_9cb0_3ddf_2c03_dfb33d745b84["setId()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 3165a179_9cb0_3ddf_2c03_dfb33d745b84
  513438f0_b49b_4a1e_b61f_b88845bcbbfb["submit()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 513438f0_b49b_4a1e_b61f_b88845bcbbfb
  c5fba347_c606_08b0_0e16_7ce79a345c9a["submit0()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| c5fba347_c606_08b0_0e16_7ce79a345c9a
  51be6bf5_0927_7649_a6a4_68f9c03c6cf5["T()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 51be6bf5_0927_7649_a6a4_68f9c03c6cf5
  6f1c910c_6e45_a6bc_feb8_0d0573381ede["isValid()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 6f1c910c_6e45_a6bc_feb8_0d0573381ede
  541ef394_3678_f3dd_de6a_f3332e5c9691["cancel()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 541ef394_3678_f3dd_de6a_f3332e5c9691
  3cf4bce8_3407_ec84_a896_3736e49852c9["tryRemove()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 3cf4bce8_3407_ec84_a896_3736e49852c9
  dbf757e6_076a_429a_e680_97e4bcade3c1["remove()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| dbf757e6_076a_429a_e680_97e4bcade3c1
  8f2a381b_f18c_57d0_86ff_b77731543e9e["close()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 8f2a381b_f18c_57d0_86ff_b77731543e9e
  47078a0b_5ca0_b127_032e_dafecdacc0ec["handle()"]
  d80a868d_a459_8e74_141b_ceb61647050d -->|method| 47078a0b_5ca0_b127_032e_dafecdacc0ec

Relationship Graph

Source Code

transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoHandler.java lines 497–607

    private final class DefaultIoUringIoRegistration implements IoRegistration {
        private final AtomicBoolean canceled = new AtomicBoolean();
        private final ThreadAwareExecutor executor;
        private final IoUringIoEvent event = new IoUringIoEvent(0, 0, (byte) 0, (short) 0);
        final IoUringIoHandle handle;

        private boolean removeLater;
        private int outstandingCompletions;
        private int id;

        DefaultIoUringIoRegistration(ThreadAwareExecutor executor, IoUringIoHandle handle) {
            this.executor = executor;
            this.handle = handle;
        }

        void setId(int id) {
            this.id = id;
        }

        @Override
        public long submit(IoOps ops) {
            IoUringIoOps ioOps = (IoUringIoOps) ops;
            if (!isValid()) {
                return INVALID_ID;
            }
            if ((ioOps.flags() & Native.IOSQE_CQE_SKIP_SUCCESS) != 0) {
                // Because we expect at least 1 completion per submission we can't support IOSQE_CQE_SKIP_SUCCESS
                // as it will only produce a completion on failure.
                throw new IllegalArgumentException("IOSQE_CQE_SKIP_SUCCESS not supported");
            }
            long udata = UserData.encode(id, ioOps.opcode(), ioOps.data());
            if (executor.isExecutorThread(Thread.currentThread())) {
                submit0(ioOps, udata);
            } else {
                executor.execute(() -> submit0(ioOps, udata));
            }
            return udata;
        }

        private void submit0(IoUringIoOps ioOps, long udata) {
            ringBuffer.ioUringSubmissionQueue().enqueueSqe(ioOps.opcode(), ioOps.flags(), ioOps.ioPrio(),
                    ioOps.fd(), ioOps.union1(), ioOps.union2(), ioOps.len(), ioOps.union3(), udata,
                    ioOps.union4(), ioOps.personality(), ioOps.union5(), ioOps.union6()
            );
            outstandingCompletions++;
        }

        @SuppressWarnings("unchecked")
        @Override
        public <T> T attachment() {
            return (T) IoUringIoHandler.this;
        }

        @Override
        public boolean isValid() {
            return !canceled.get();
        }

        @Override
        public boolean cancel() {
            if (!canceled.compareAndSet(false, true)) {
                // Already cancelled.
                return false;
            }
            if (executor.isExecutorThread(Thread.currentThread())) {
                tryRemove();
            } else {
                executor.execute(this::tryRemove);
            }
            return true;
        }

        private void tryRemove() {
            if (outstandingCompletions > 0) {
                // We have some completions outstanding, we will remove the id <-> registration mapping
                // once these are done.
                removeLater = true;
                return;
            }
            remove();
        }

Frequently Asked Questions

What is the DefaultIoUringIoRegistration class?
DefaultIoUringIoRegistration is a class in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoHandler.java.
Where is DefaultIoUringIoRegistration defined?
DefaultIoUringIoRegistration is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoHandler.java at line 497.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free