Home / Function/ testSelectableChannel() — netty Function Reference

testSelectableChannel() — netty Function Reference

Architecture documentation for the testSelectableChannel() function in NioEventLoopTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  436455f6_85bd_af95_b8cb_0fb25d2f869e["testSelectableChannel()"]
  744640b8_9d8b_07b6_4d95_821961ea4e63["NioEventLoopTest"]
  436455f6_85bd_af95_b8cb_0fb25d2f869e -->|defined in| 744640b8_9d8b_07b6_4d95_821961ea4e63
  style 436455f6_85bd_af95_b8cb_0fb25d2f869e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/nio/NioEventLoopTest.java lines 166–200

    @Test
    @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
    public void testSelectableChannel() throws Exception {
        IoEventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
        IoEventLoop loop = group.next();

        try {
            Channel channel = new NioServerSocketChannel();
            loop.register(channel).syncUninterruptibly();
            channel.bind(new InetSocketAddress(0)).syncUninterruptibly();

            SocketChannel selectableChannel = SocketChannel.open();
            selectableChannel.configureBlocking(false);
            selectableChannel.connect(channel.localAddress());

            final CountDownLatch latch = new CountDownLatch(1);

            IoRegistration registration = loop.register(
                            new NioSelectableChannelIoHandle<SocketChannel>(selectableChannel) {
                @Override
                protected void handle(SocketChannel channel, SelectionKey key) {
                    latch.countDown();
                }
            }).get();

            registration.submit(NioIoOps.valueOf(SelectionKey.OP_CONNECT));

            latch.await();

            selectableChannel.close();
            channel.close().syncUninterruptibly();
        } finally {
            group.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSelectableChannel() do?
testSelectableChannel() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/nio/NioEventLoopTest.java.
Where is testSelectableChannel() defined?
testSelectableChannel() is defined in transport/src/test/java/io/netty/channel/nio/NioEventLoopTest.java at line 166.

Analyze Your Own Codebase

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

Try Supermodel Free