Skip to content

Commit

Permalink
Change apply->set
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Oct 3, 2023
1 parent 14cfdd4 commit d5fd724
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import jdk.jfr.internal.context.ContextWriter;

public abstract class BaseContextType {
public final void apply() {
public final void set() {
if (shouldCaptureState()) {
ContextRepository.getOrRegister(this.getClass()).write(this);
}
}

public final void clear() {
public final void unset() {
if (shouldCaptureState()) {
ContextRepository.getOrRegister(this.getClass()).clear(this);
}
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/jdk/jfr/api/context/TestJfrContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static void main(String[] args) throws Throwable {
TestContextType captured = new TestContextType();
captured.state = "enabled";
captured.result = "FALSE";
captured.apply();
captured.set();

ClassLoader classLoader = TestJfrContext.class.getClassLoader();
Class<? extends Event> eventClass =
Expand All @@ -116,7 +116,7 @@ public static void main(String[] args) throws Throwable {
r.enable(eventClass).withThreshold(Duration.ofMillis(0)).withoutStackTrace();
captured.state = "disabled";
captured.result = "TRUE";
captured.apply();
captured.set();
synchronized (captured) {
TooLargeContextType tlct = new TooLargeContextType();
tlct.attr1 = "value1";
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/jdk/jfr/api/context/TestJfrContextVirtual.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void main(String[] args) throws Throwable {
TestContextType captured = new TestContextType();
// Any context-aware event emitted after the context was set wil contain the context fields
captured.taskid = "Task " + id;
captured.apply();
captured.set();

SimpleEvent e1 = new SimpleEvent();
e1.id = id;
Expand Down
5 changes: 2 additions & 3 deletions test/micro/org/openjdk/bench/jdk/jfr/JfrContextBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import jdk.jfr.ContextType;
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
import jdk.jfr.context.ContextRegistration;

@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
Expand Down Expand Up @@ -44,9 +43,9 @@ public void operationWithContext(Blackhole bh) throws IOException {
TracingJfrContext ctx = new TracingJfrContext();
ctx.traceid = "trace-1";
ctx.spanid = "span-1";
ctx.apply();
ctx.set();
TracedEvent.commit(10);
ctx.clear();
ctx.unset();
bh.consume(ctx);
}
}

0 comments on commit d5fd724

Please sign in to comment.