testDirectSubpageReleaseLock() — netty Function Reference
Architecture documentation for the testDirectSubpageReleaseLock() function in AlignedPooledByteBufAllocatorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 894fa3c1_f240_ab16_8e00_0f1104ec04a9["testDirectSubpageReleaseLock()"] c9134dc8_fd93_c39d_23b0_5a7607e27734["AlignedPooledByteBufAllocatorTest"] 894fa3c1_f240_ab16_8e00_0f1104ec04a9 -->|defined in| c9134dc8_fd93_c39d_23b0_5a7607e27734 98e9fd03_54b3_2543_c93d_fcc6739e25e3["PooledByteBufAllocator()"] 894fa3c1_f240_ab16_8e00_0f1104ec04a9 -->|calls| 98e9fd03_54b3_2543_c93d_fcc6739e25e3 7544fc70_1ef8_cfbc_0e8a_918b0ce362ee["pooledByteBuf()"] 894fa3c1_f240_ab16_8e00_0f1104ec04a9 -->|calls| 7544fc70_1ef8_cfbc_0e8a_918b0ce362ee style 894fa3c1_f240_ab16_8e00_0f1104ec04a9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/AlignedPooledByteBufAllocatorTest.java lines 73–127
@Test
public void testDirectSubpageReleaseLock() throws InterruptedException {
assumeTrue(PooledByteBufAllocator.isDirectMemoryCacheAlignmentSupported());
int initialCapacity = 0;
int directMemoryCacheAlignment = 32;
PooledByteBufAllocator allocator = new PooledByteBufAllocator(
true,
0,
1,
PooledByteBufAllocator.defaultPageSize(),
PooledByteBufAllocator.defaultMaxOrder(),
0,
0,
false,
directMemoryCacheAlignment);
final ByteBuf wrapper = allocator.directBuffer(initialCapacity, 16);
PooledByteBuf<?> unwrapped = pooledByteBuf(wrapper);
// Get the smallSubpagePools[] array in arena.
@SuppressWarnings("unchecked")
PoolSubpage<byte[]>[] smallSubpagePools = (PoolSubpage<byte[]>[]) unwrapped.chunk.arena.smallSubpagePools;
PoolSubpage<byte[]> head = null;
for (PoolSubpage<byte[]> subpage : smallSubpagePools) {
if (subpage.next != subpage) {
// Find the head subpage which the byteBuf belongs to.
head = subpage;
break;
}
}
assertNotNull(head);
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
// Because the head subpage was already locked in the main thread, so this should hang and wait.
wrapper.release();
}
});
t1.setDaemon(true);
// Intentionally lock the head subpage in main thread.
head.lock();
try {
t1.start();
long start = System.nanoTime();
while (!head.lock.hasQueuedThread(t1)) {
if ((System.nanoTime() - start) > TimeUnit.SECONDS.toNanos(3)) {
break;
}
}
assertTrue(head.lock.hasQueuedThread(t1),
"The t1 thread should still be waiting for the head lock.");
} finally {
head.unlock();
}
t1.join();
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testDirectSubpageReleaseLock() do?
testDirectSubpageReleaseLock() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AlignedPooledByteBufAllocatorTest.java.
Where is testDirectSubpageReleaseLock() defined?
testDirectSubpageReleaseLock() is defined in buffer/src/test/java/io/netty/buffer/AlignedPooledByteBufAllocatorTest.java at line 73.
What does testDirectSubpageReleaseLock() call?
testDirectSubpageReleaseLock() calls 2 function(s): PooledByteBufAllocator, pooledByteBuf.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free