testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() — netty Function Reference
Architecture documentation for the testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() function in RecyclerFastThreadLocalTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d8f9d3a3_3377_f367_9708_cc358351a7a5["testThreadCanBeCollectedEvenIfHandledObjectIsReferenced()"] 785d6cb4_3c02_ed7e_3786_f92f3033392b["RecyclerFastThreadLocalTest"] d8f9d3a3_3377_f367_9708_cc358351a7a5 -->|defined in| 785d6cb4_3c02_ed7e_3786_f92f3033392b style d8f9d3a3_3377_f367_9708_cc358351a7a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/RecyclerFastThreadLocalTest.java lines 39–84
@Override
@ParameterizedTest
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
@MethodSource("ownerTypeAndUnguarded")
public void testThreadCanBeCollectedEvenIfHandledObjectIsReferenced(OwnerType ownerType, boolean unguarded)
throws Exception {
final AtomicBoolean collected = new AtomicBoolean();
final AtomicReference<HandledObject> reference = new AtomicReference<HandledObject>();
Thread thread = new FastThreadLocalThread(new Runnable() {
@Override
public void run() {
final Recycler<HandledObject> recycler = newRecycler(ownerType, unguarded, 1024);
HandledObject object = recycler.get();
// Store a reference to the HandledObject to ensure it is not collected when the run method finish.
reference.set(object);
Recycler.unpinOwner(recycler);
}
}) {
@Override
protected void finalize() throws Throwable {
try {
collected.set(true);
} finally {
super.finalize();
}
}
};
assertFalse(collected.get());
thread.start();
thread.join();
// Null out so it can be collected.
thread = null;
// Loop until the Thread was collected. If we can not collect it the Test will fail due of a timeout.
while (!collected.get()) {
System.gc();
System.runFinalization();
Thread.sleep(50);
}
// Now call recycle after the Thread was collected to ensure this still works...
if (reference.get() != null) {
reference.getAndSet(null).recycle();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() do?
testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/RecyclerFastThreadLocalTest.java.
Where is testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() defined?
testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() is defined in common/src/test/java/io/netty/util/RecyclerFastThreadLocalTest.java at line 39.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free