src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java
branchJEP-349-branch
changeset 58165 8584c5b96cb6
parent 57946 b77540d274f9
child 58567 e77a97d0edbb
equal deleted inserted replaced
58164:1343c01b29d5 58165:8584c5b96cb6
    61     private final Map<String, Class<? extends Event>> mirrors = new HashMap<>();
    61     private final Map<String, Class<? extends Event>> mirrors = new HashMap<>();
    62     private boolean staleMetadata = true;
    62     private boolean staleMetadata = true;
    63     private boolean unregistered;
    63     private boolean unregistered;
    64     private long lastUnloaded = -1;
    64     private long lastUnloaded = -1;
    65     private boolean flushMetadata;
    65     private boolean flushMetadata;
    66     private short flushCounter = 0;
       
    67 
    66 
    68     public MetadataRepository() {
    67     public MetadataRepository() {
    69         initializeJVMEventTypes();
    68         initializeJVMEventTypes();
    70     }
    69     }
    71 
    70 
   278             unregistered = false;
   277             unregistered = false;
   279         }
   278         }
   280         if (staleMetadata) {
   279         if (staleMetadata) {
   281             storeDescriptorInJVM();
   280             storeDescriptorInJVM();
   282         }
   281         }
   283         flushCounter = 0;
       
   284     }
   282     }
   285 
   283 
   286     private void unregisterUnloaded() {
   284     private void unregisterUnloaded() {
   287         long unloaded = jvm.getUnloadedEventClassCount();
   285         long unloaded = jvm.getUnloadedEventClassCount();
   288         if (this.lastUnloaded != unloaded) {
   286         if (this.lastUnloaded != unloaded) {
   318         }
   316         }
   319         throw new InternalError("Mirror class must have annotation " + MirrorEvent.class.getName());
   317         throw new InternalError("Mirror class must have annotation " + MirrorEvent.class.getName());
   320     }
   318     }
   321 
   319 
   322     public synchronized void flush() {
   320     public synchronized void flush() {
   323         jvm.flush(flushMetadata || flushCounter == 0, ++flushCounter);
   321         jvm.flush(flushMetadata);
   324         if (flushCounter == Short.MAX_VALUE) {
       
   325             flushCounter = 0;
       
   326         }
       
   327         this.flushMetadata = false;
   322         this.flushMetadata = false;
   328     }
   323     }
   329 
   324 
   330 
   325 
   331 
   326