Home / Function/ testScheduleTaskAtFixedRate() — netty Function Reference

testScheduleTaskAtFixedRate() — netty Function Reference

Architecture documentation for the testScheduleTaskAtFixedRate() function in SingleThreadEventLoopTest.java from the netty codebase.

Function java Buffer Search calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  ba499c81_3a16_c6c4_23e5_d0f6f0b8972f["testScheduleTaskAtFixedRate()"]
  42a05bb6_77d1_5163_f1de_dc06e1ae82b0["SingleThreadEventLoopTest"]
  ba499c81_3a16_c6c4_23e5_d0f6f0b8972f -->|defined in| 42a05bb6_77d1_5163_f1de_dc06e1ae82b0
  cb4cdc2e_011b_438a_b460_d629715f5734["scheduleTaskAtFixedRateA()"]
  cb4cdc2e_011b_438a_b460_d629715f5734 -->|calls| ba499c81_3a16_c6c4_23e5_d0f6f0b8972f
  9fbfe781_74c5_0b85_e140_f04a27acd80c["scheduleTaskAtFixedRateB()"]
  9fbfe781_74c5_0b85_e140_f04a27acd80c -->|calls| ba499c81_3a16_c6c4_23e5_d0f6f0b8972f
  b79014df_fa4d_f5ee_0fee_b9e3906bd3e9["run()"]
  ba499c81_3a16_c6c4_23e5_d0f6f0b8972f -->|calls| b79014df_fa4d_f5ee_0fee_b9e3906bd3e9
  style ba499c81_3a16_c6c4_23e5_d0f6f0b8972f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java lines 187–223

    private static void testScheduleTaskAtFixedRate(EventLoop loopA) throws InterruptedException {
        final Queue<Long> timestamps = new LinkedBlockingQueue<Long>();
        final int expectedTimeStamps = 5;
        final CountDownLatch allTimeStampsLatch = new CountDownLatch(expectedTimeStamps);
        ScheduledFuture<?> f = loopA.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                timestamps.add(System.nanoTime());
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    // Ignore
                }
                allTimeStampsLatch.countDown();
            }
        }, 100, 100, TimeUnit.MILLISECONDS);
        allTimeStampsLatch.await();
        assertTrue(f.cancel(true));
        Thread.sleep(300);
        assertEquals(expectedTimeStamps, timestamps.size());

        // Check if the task was run without a lag.
        Long firstTimestamp = null;
        int cnt = 0;
        for (Long t: timestamps) {
            if (firstTimestamp == null) {
                firstTimestamp = t;
                continue;
            }

            long timepoint = t - firstTimestamp;
            assertThat(timepoint).isGreaterThanOrEqualTo(TimeUnit.MILLISECONDS.toNanos(100 * cnt + 80));
            assertThat(timepoint).isLessThan(TimeUnit.MILLISECONDS.toNanos(100 * (cnt + 1) + 20));

            cnt ++;
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does testScheduleTaskAtFixedRate() do?
testScheduleTaskAtFixedRate() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java.
Where is testScheduleTaskAtFixedRate() defined?
testScheduleTaskAtFixedRate() is defined in transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java at line 187.
What does testScheduleTaskAtFixedRate() call?
testScheduleTaskAtFixedRate() calls 1 function(s): run.
What calls testScheduleTaskAtFixedRate()?
testScheduleTaskAtFixedRate() is called by 2 function(s): scheduleTaskAtFixedRateA, scheduleTaskAtFixedRateB.

Analyze Your Own Codebase

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

Try Supermodel Free