src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java
branchJEP-349-branch
changeset 57459 df39f8d8f4d6
parent 57360 5d043a159d5c
child 57690 9316d02dd4a5
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java	Fri Jul 05 17:11:55 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java	Mon Jul 08 18:11:26 2019 +0200
@@ -65,17 +65,17 @@
 
 public final class Utils {
 
+    private static final Object flushObject = new Object();
     private static final String INFINITY = "infinity";
-
-    private static Boolean SAVE_GENERATED;
-
     public static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events";
     public static final String INSTRUMENT_PACKAGE_NAME = "jdk.jfr.internal.instrument";
     public static final String HANDLERS_PACKAGE_NAME = "jdk.jfr.internal.handlers";
     public static final String REGISTER_EVENT = "registerEvent";
     public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder";
+    private final static String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk.";
 
-    private final static String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk.";
+    private static Boolean SAVE_GENERATED;
+
 
     public static void checkAccessFlightRecorder() throws SecurityException {
         SecurityManager sm = System.getSecurityManager();
@@ -595,10 +595,28 @@
         String idText = recording == null ? "" :  "-id-" + Long.toString(recording.getId());
         return "hotspot-" + "pid-" + pid + idText + "-" + date + ".jfr";
     }
+
     public static void takeNap(long millis) {
         try {
             Thread.sleep(millis);
         } catch (InterruptedException e) {
         }
     }
+
+    public static void notifyFlush() {
+        synchronized (flushObject) {
+            flushObject.notifyAll();
+        }
+    }
+
+    public static void waitFlush(long timeOut) {
+        synchronized (flushObject) {
+            try {
+                flushObject.wait(timeOut);
+            } catch (InterruptedException e) {
+                // OK
+            }
+        }
+
+    }
 }