Home / Function/ testSignalRace() — netty Function Reference

testSignalRace() — netty Function Reference

Architecture documentation for the testSignalRace() function in DefaultPromiseTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ea2f93e5_1dcf_ff20_72e8_f85b2caaaeaf["testSignalRace()"]
  18d135a2_101c_bae7_e68f_dd4660e1fb75["DefaultPromiseTest"]
  ea2f93e5_1dcf_ff20_72e8_f85b2caaaeaf -->|defined in| 18d135a2_101c_bae7_e68f_dd4660e1fb75
  7ea2f073_8f06_492d_3ce0_3651a2c14c01["TestEventExecutor()"]
  ea2f93e5_1dcf_ff20_72e8_f85b2caaaeaf -->|calls| 7ea2f073_8f06_492d_3ce0_3651a2c14c01
  91d7c04c_78df_5079_c536_a87d3e68b6fb["run()"]
  ea2f93e5_1dcf_ff20_72e8_f85b2caaaeaf -->|calls| 91d7c04c_78df_5079_c536_a87d3e68b6fb
  817c8cdd_038c_e049_c910_fd52454e0e8d["shutdownGracefully()"]
  ea2f93e5_1dcf_ff20_72e8_f85b2caaaeaf -->|calls| 817c8cdd_038c_e049_c910_fd52454e0e8d
  style ea2f93e5_1dcf_ff20_72e8_f85b2caaaeaf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java lines 332–363

    @Test
    public void testSignalRace() {
        final long wait = TimeUnit.NANOSECONDS.convert(10, TimeUnit.SECONDS);
        EventExecutor executor = null;
        try {
            executor = new TestEventExecutor();

            final int numberOfAttempts = 4096;
            final Map<Thread, DefaultPromise<Void>> promises = new HashMap<Thread, DefaultPromise<Void>>();
            for (int i = 0; i < numberOfAttempts; i++) {
                final DefaultPromise<Void> promise = new DefaultPromise<Void>(executor);
                final Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        promise.setSuccess(null);
                    }
                });
                promises.put(thread, promise);
            }

            for (final Map.Entry<Thread, DefaultPromise<Void>> promise : promises.entrySet()) {
                promise.getKey().start();
                final long start = System.nanoTime();
                promise.getValue().awaitUninterruptibly(wait, TimeUnit.NANOSECONDS);
                assertThat(System.nanoTime() - start).isLessThan(wait);
            }
        } finally {
            if (executor != null) {
                executor.shutdownGracefully();
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSignalRace() do?
testSignalRace() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java.
Where is testSignalRace() defined?
testSignalRace() is defined in common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java at line 332.
What does testSignalRace() call?
testSignalRace() calls 3 function(s): TestEventExecutor, run, shutdownGracefully.

Analyze Your Own Codebase

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

Try Supermodel Free