8331189: Implementation of Scoped Values (Third Preview)

Reviewed-by: aph, jpai, mcimadamore
This commit is contained in:
Alan Bateman 2024-05-30 15:41:56 +00:00
parent 4acafb809c
commit 707154235b
7 changed files with 96 additions and 268 deletions

View file

@ -24,9 +24,8 @@
package org.openjdk.bench.java.lang;
import java.util.concurrent.Callable;
import java.lang.ScopedValue.CallableOp;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
@ -164,18 +163,9 @@ public class ScopedValues {
@Benchmark
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Object bind_ScopedValue() throws Exception {
return HOLD_42.call(aCallable);
return HOLD_42.call(aCallableOp);
}
private static final Callable<Class<?>> aCallable = () -> ScopedValues.class;
// Same, but make sure that Carrier.get(Supplier) is no slower
// than Carrier.call(Callable).
@Benchmark
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Object bindViaGet_ScopedValue() {
return HOLD_42.get(aSupplier);
}
private static final Supplier<Class<?>> aSupplier = () -> ScopedValues.class;
private static final CallableOp<Class<?>, RuntimeException> aCallableOp = () -> ScopedValues.class;
@Benchmark
@OutputTimeUnit(TimeUnit.NANOSECONDS)