mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 12:37:42 +01:00
More tests for array/pool
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
ace42b6f46
commit
188d316e15
@ -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<BinaryBuffer> 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();
|
||||
}
|
||||
}
|
@ -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<Integer> 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user