8302821: JFR: Periodic task thread spins after recording has stopped
Reviewed-by: mgronlun
This commit is contained in:
parent
4d33fbd582
commit
6b24b4a70f
@ -72,6 +72,7 @@ public final class PlatformRecorder {
|
||||
private long recordingCounter = 0;
|
||||
private RepositoryChunk currentChunk;
|
||||
private boolean inShutdown;
|
||||
private boolean runPeriodicTask;
|
||||
|
||||
public PlatformRecorder() throws Exception {
|
||||
repository = Repository.getRepository();
|
||||
@ -252,6 +253,7 @@ public final class PlatformRecorder {
|
||||
updateSettings(false);
|
||||
recording.setStartTime(startTime);
|
||||
writeMetaEvents();
|
||||
setRunPeriodicTask(true);
|
||||
} else {
|
||||
RepositoryChunk newChunk = null;
|
||||
if (toDisk) {
|
||||
@ -329,6 +331,7 @@ public final class PlatformRecorder {
|
||||
jvm.endRecording();
|
||||
recording.setStopTime(stopTime);
|
||||
disableEvents();
|
||||
setRunPeriodicTask(false);
|
||||
} else {
|
||||
RepositoryChunk newChunk = null;
|
||||
PeriodicEvents.doChunkEnd();
|
||||
@ -518,9 +521,21 @@ public final class PlatformRecorder {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setRunPeriodicTask(boolean runPeriodicTask) {
|
||||
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
|
||||
this.runPeriodicTask = runPeriodicTask;
|
||||
if (runPeriodicTask) {
|
||||
JVM.CHUNK_ROTATION_MONITOR.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void takeNap(long duration) {
|
||||
try {
|
||||
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
|
||||
if (!runPeriodicTask) {
|
||||
duration = Long.MAX_VALUE;
|
||||
}
|
||||
JVM.CHUNK_ROTATION_MONITOR.wait(duration < 10 ? 10 : duration);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user