testDiscardingExceedingElementsWithRecycleAtDifferentThread() — netty Function Reference
Architecture documentation for the testDiscardingExceedingElementsWithRecycleAtDifferentThread() function in RecyclerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 0babcd4b_ce2c_a062_e807_886bbf9b4d1d["testDiscardingExceedingElementsWithRecycleAtDifferentThread()"] 46ac14b1_2382_5afa_98f3_803182070b38["RecyclerTest"] 0babcd4b_ce2c_a062_e807_886bbf9b4d1d -->|defined in| 46ac14b1_2382_5afa_98f3_803182070b38 87dca999_f804_a974_e326_fd8f527f1246["newRecycler()"] 0babcd4b_ce2c_a062_e807_886bbf9b4d1d -->|calls| 87dca999_f804_a974_e326_fd8f527f1246 43ab40f6_52e7_0fe9_a79f_220021939268["recycle()"] 0babcd4b_ce2c_a062_e807_886bbf9b4d1d -->|calls| 43ab40f6_52e7_0fe9_a79f_220021939268 style 0babcd4b_ce2c_a062_e807_886bbf9b4d1d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/RecyclerTest.java lines 557–602
@ParameterizedTest
@MethodSource("notNoneOwnerAndUnguarded")
public void testDiscardingExceedingElementsWithRecycleAtDifferentThread(OwnerType ownerType, boolean unguarded)
throws Exception {
final int maxCapacity = 32;
final AtomicInteger instancesCount = new AtomicInteger(0);
final Recycler<HandledObject> recycler = newRecycler(ownerType, unguarded, maxCapacity, ignore ->
instancesCount.incrementAndGet());
// Borrow 2 * maxCapacity objects.
final HandledObject[] array = new HandledObject[maxCapacity * 2];
for (int i = 0; i < array.length; i++) {
array[i] = recycler.get();
}
assertEquals(array.length, instancesCount.get());
// Reset counter.
instancesCount.set(0);
// Recycle from other thread.
final Thread thread = newThread(new Runnable() {
@Override
public void run() {
for (HandledObject object: array) {
object.recycle();
}
}
});
thread.start();
thread.join();
assertEquals(0, instancesCount.get());
// Borrow 2 * maxCapacity objects. Half of them should come from
// the recycler queue, the other half should be freshly allocated.
for (int i = 0; i < array.length; i++) {
recycler.get();
}
// The implementation uses maxCapacity / 2 as limit per WeakOrderQueue
assertTrue(array.length - maxCapacity / 2 <= instancesCount.get(),
"The instances count (" + instancesCount.get() + ") must be <= array.length (" + array.length
+ ") - maxCapacity (" + maxCapacity + ") / 2 as we not pool all new handles" +
" internally");
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testDiscardingExceedingElementsWithRecycleAtDifferentThread() do?
testDiscardingExceedingElementsWithRecycleAtDifferentThread() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/RecyclerTest.java.
Where is testDiscardingExceedingElementsWithRecycleAtDifferentThread() defined?
testDiscardingExceedingElementsWithRecycleAtDifferentThread() is defined in common/src/test/java/io/netty/util/RecyclerTest.java at line 557.
What does testDiscardingExceedingElementsWithRecycleAtDifferentThread() call?
testDiscardingExceedingElementsWithRecycleAtDifferentThread() calls 2 function(s): newRecycler, recycle.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free