Home / Function/ testMultipleRecycleAtDifferentThreadRacing() — netty Function Reference

testMultipleRecycleAtDifferentThreadRacing() — netty Function Reference

Architecture documentation for the testMultipleRecycleAtDifferentThreadRacing() function in RecyclerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d5663849_f9de_1a49_00a8_bc360fe5bd24["testMultipleRecycleAtDifferentThreadRacing()"]
  46ac14b1_2382_5afa_98f3_803182070b38["RecyclerTest"]
  d5663849_f9de_1a49_00a8_bc360fe5bd24 -->|defined in| 46ac14b1_2382_5afa_98f3_803182070b38
  87dca999_f804_a974_e326_fd8f527f1246["newRecycler()"]
  d5663849_f9de_1a49_00a8_bc360fe5bd24 -->|calls| 87dca999_f804_a974_e326_fd8f527f1246
  43ab40f6_52e7_0fe9_a79f_220021939268["recycle()"]
  d5663849_f9de_1a49_00a8_bc360fe5bd24 -->|calls| 43ab40f6_52e7_0fe9_a79f_220021939268
  style d5663849_f9de_1a49_00a8_bc360fe5bd24 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/test/java/io/netty/util/RecyclerTest.java lines 280–338

    @ParameterizedTest
    @EnumSource(OwnerType.class)
    public void testMultipleRecycleAtDifferentThreadRacing(OwnerType ownerType)
            throws InterruptedException {
        // This test makes only sense for guarded recyclers
        Recycler<HandledObject> recycler = newRecycler(ownerType, false, 1024);
        final HandledObject object = recycler.get();
        final AtomicReference<IllegalStateException> exceptionStore = new AtomicReference<IllegalStateException>();

        final CountDownLatch countDownLatch = new CountDownLatch(2);
        final Thread thread1 = newThread(new Runnable() {
            @Override
            public void run() {
                try {
                    object.recycle();
                } catch (IllegalStateException e) {
                    Exception x = exceptionStore.getAndSet(e);
                    if (x != null) {
                        e.addSuppressed(x);
                    }
                } finally {
                    countDownLatch.countDown();
                }
            }
        });
        thread1.start();

        final Thread thread2 = newThread(new Runnable() {
            @Override
            public void run() {
                try {
                    object.recycle();
                } catch (IllegalStateException e) {
                    Exception x = exceptionStore.getAndSet(e);
                    if (x != null) {
                        e.addSuppressed(x);
                    }
                } finally {
                    countDownLatch.countDown();
                }
            }
        });
        thread2.start();

        try {
            countDownLatch.await();
            HandledObject a = recycler.get();
            HandledObject b = recycler.get();
            assertNotSame(a, b);
            IllegalStateException exception = exceptionStore.get();
            if (exception != null) {
                assertThat(exception).hasMessageContaining("recycled already");
                assertEquals(0, exception.getSuppressed().length);
            }
        } finally {
            thread1.join(1000);
            thread2.join(1000);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testMultipleRecycleAtDifferentThreadRacing() do?
testMultipleRecycleAtDifferentThreadRacing() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/RecyclerTest.java.
Where is testMultipleRecycleAtDifferentThreadRacing() defined?
testMultipleRecycleAtDifferentThreadRacing() is defined in common/src/test/java/io/netty/util/RecyclerTest.java at line 280.
What does testMultipleRecycleAtDifferentThreadRacing() call?
testMultipleRecycleAtDifferentThreadRacing() 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