testScheduleLaggyTaskAtFixedRate() — netty Function Reference
Architecture documentation for the testScheduleLaggyTaskAtFixedRate() function in SingleThreadEventLoopTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c0fdb18d_8a78_4da8_0236_af9141b2839b["testScheduleLaggyTaskAtFixedRate()"] 42a05bb6_77d1_5163_f1de_dc06e1ae82b0["SingleThreadEventLoopTest"] c0fdb18d_8a78_4da8_0236_af9141b2839b -->|defined in| 42a05bb6_77d1_5163_f1de_dc06e1ae82b0 754ae531_9319_618c_34c8_f2557f647124["scheduleLaggyTaskAtFixedRateA()"] 754ae531_9319_618c_34c8_f2557f647124 -->|calls| c0fdb18d_8a78_4da8_0236_af9141b2839b ca54ce44_c0c9_13ee_09aa_f9f804a6dbff["scheduleLaggyTaskAtFixedRateB()"] ca54ce44_c0c9_13ee_09aa_f9f804a6dbff -->|calls| c0fdb18d_8a78_4da8_0236_af9141b2839b b79014df_fa4d_f5ee_0fee_b9e3906bd3e9["run()"] c0fdb18d_8a78_4da8_0236_af9141b2839b -->|calls| b79014df_fa4d_f5ee_0fee_b9e3906bd3e9 style c0fdb18d_8a78_4da8_0236_af9141b2839b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java lines 237–279
private static void testScheduleLaggyTaskAtFixedRate(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() {
boolean empty = timestamps.isEmpty();
timestamps.add(System.nanoTime());
if (empty) {
try {
Thread.sleep(401);
} 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 with lag.
int i = 0;
Long previousTimestamp = null;
for (Long t: timestamps) {
if (previousTimestamp == null) {
previousTimestamp = t;
continue;
}
long diff = t.longValue() - previousTimestamp.longValue();
if (i == 0) {
assertThat(diff).isGreaterThanOrEqualTo(TimeUnit.MILLISECONDS.toNanos(400));
} else {
assertThat(diff).isLessThanOrEqualTo(TimeUnit.MILLISECONDS.toNanos(10));
}
previousTimestamp = t;
i ++;
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testScheduleLaggyTaskAtFixedRate() do?
testScheduleLaggyTaskAtFixedRate() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java.
Where is testScheduleLaggyTaskAtFixedRate() defined?
testScheduleLaggyTaskAtFixedRate() is defined in transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java at line 237.
What does testScheduleLaggyTaskAtFixedRate() call?
testScheduleLaggyTaskAtFixedRate() calls 1 function(s): run.
What calls testScheduleLaggyTaskAtFixedRate()?
testScheduleLaggyTaskAtFixedRate() is called by 2 function(s): scheduleLaggyTaskAtFixedRateA, scheduleLaggyTaskAtFixedRateB.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free