diff --git a/jcstress-tests/src/jcstress/java/net/minestom/server/utils/ObjectPoolTest.java b/jcstress-tests/src/jcstress/java/net/minestom/server/utils/ObjectPoolTest.java new file mode 100644 index 000000000..92e0fdeec --- /dev/null +++ b/jcstress-tests/src/jcstress/java/net/minestom/server/utils/ObjectPoolTest.java @@ -0,0 +1,32 @@ +package net.minestom.server.utils; + +import net.minestom.server.utils.binary.BinaryBuffer; +import org.openjdk.jcstress.annotations.*; +import org.openjdk.jcstress.infra.results.L_Result; + +import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE; + +@JCStressTest +@Outcome(id = "1", expect = ACCEPTABLE) +@Outcome(id = "2", expect = ACCEPTABLE) +@State +public class ObjectPoolTest { + private final ObjectPool pool = ObjectPool.BUFFER_POOL; + + @Actor + public void actor1() { + var buffer = pool.get(); + pool.add(buffer); + } + + @Actor + public void actor2() { + var buffer = pool.get(); + pool.add(buffer); + } + + @Arbiter + public void arbiter(L_Result r) { + r.r1 = pool.count(); + } +} diff --git a/jcstress-tests/src/jcstress/java/net/minestom/server/utils/collection/ObjectArrayTest.java b/jcstress-tests/src/jcstress/java/net/minestom/server/utils/collection/ObjectArrayTest.java new file mode 100644 index 000000000..8a146e1c7 --- /dev/null +++ b/jcstress-tests/src/jcstress/java/net/minestom/server/utils/collection/ObjectArrayTest.java @@ -0,0 +1,29 @@ +package net.minestom.server.utils.collection; + +import org.openjdk.jcstress.annotations.*; +import org.openjdk.jcstress.infra.results.LL_Result; + +import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE; + +@JCStressTest +@Outcome(id = "1, 2", expect = ACCEPTABLE) +@State +public class ObjectArrayTest { + private final ObjectArray array = ObjectArray.concurrent(); + + @Actor + public void actor1() { + array.set(255, 1); + } + + @Actor + public void actor2() { + array.set(32_000, 2); + } + + @Arbiter + public void arbiter(LL_Result r) { + r.r1 = array.get(255); + r.r2 = array.get(32_000); + } +}