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 long recordingCounter = 0;
|
||||||
private RepositoryChunk currentChunk;
|
private RepositoryChunk currentChunk;
|
||||||
private boolean inShutdown;
|
private boolean inShutdown;
|
||||||
|
private boolean runPeriodicTask;
|
||||||
|
|
||||||
public PlatformRecorder() throws Exception {
|
public PlatformRecorder() throws Exception {
|
||||||
repository = Repository.getRepository();
|
repository = Repository.getRepository();
|
||||||
@ -252,6 +253,7 @@ public final class PlatformRecorder {
|
|||||||
updateSettings(false);
|
updateSettings(false);
|
||||||
recording.setStartTime(startTime);
|
recording.setStartTime(startTime);
|
||||||
writeMetaEvents();
|
writeMetaEvents();
|
||||||
|
setRunPeriodicTask(true);
|
||||||
} else {
|
} else {
|
||||||
RepositoryChunk newChunk = null;
|
RepositoryChunk newChunk = null;
|
||||||
if (toDisk) {
|
if (toDisk) {
|
||||||
@ -329,6 +331,7 @@ public final class PlatformRecorder {
|
|||||||
jvm.endRecording();
|
jvm.endRecording();
|
||||||
recording.setStopTime(stopTime);
|
recording.setStopTime(stopTime);
|
||||||
disableEvents();
|
disableEvents();
|
||||||
|
setRunPeriodicTask(false);
|
||||||
} else {
|
} else {
|
||||||
RepositoryChunk newChunk = null;
|
RepositoryChunk newChunk = null;
|
||||||
PeriodicEvents.doChunkEnd();
|
PeriodicEvents.doChunkEnd();
|
||||||
@ -518,9 +521,21 @@ public final class PlatformRecorder {
|
|||||||
return false;
|
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) {
|
private void takeNap(long duration) {
|
||||||
try {
|
try {
|
||||||
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
|
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
|
||||||
|
if (!runPeriodicTask) {
|
||||||
|
duration = Long.MAX_VALUE;
|
||||||
|
}
|
||||||
JVM.CHUNK_ROTATION_MONITOR.wait(duration < 10 ? 10 : duration);
|
JVM.CHUNK_ROTATION_MONITOR.wait(duration < 10 ? 10 : duration);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user