diff src/share/vm/runtime/serviceThread.cpp @ 3356:78542e2b5e35

7036199: Adding a notification to the implementation of GarbageCollectorMXBeans Summary: Add a notification to the GarbageCollectorMXBeans Reviewed-by: acorn, mchung
author fparain
date Thu, 12 May 2011 10:30:11 -0700
parents 216d916d5c12
children 31a4e55f8c9d
line wrap: on
line diff
--- a/src/share/vm/runtime/serviceThread.cpp	Wed May 11 13:19:53 2011 -0400
+++ b/src/share/vm/runtime/serviceThread.cpp	Thu May 12 10:30:11 2011 -0700
@@ -28,6 +28,7 @@
 #include "runtime/serviceThread.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "prims/jvmtiImpl.hpp"
+#include "services/gcNotifier.hpp"
 
 ServiceThread* ServiceThread::_instance = NULL;
 
@@ -81,6 +82,7 @@
   while (true) {
     bool sensors_changed = false;
     bool has_jvmti_events = false;
+    bool has_gc_notification_event = false;
     JvmtiDeferredEvent jvmti_event;
     {
       // Need state transition ThreadBlockInVM so that this thread
@@ -95,9 +97,10 @@
 
       MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
       while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) &&
-             !(has_jvmti_events = JvmtiDeferredEventQueue::has_events())) {
+             !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) &&
+              !(has_gc_notification_event = GCNotifier::has_event())) {
         // wait until one of the sensors has pending requests, or there is a
-        // pending JVMTI event to post
+        // pending JVMTI event or JMX GC notification to post
         Service_lock->wait(Mutex::_no_safepoint_check_flag);
       }
 
@@ -113,6 +116,10 @@
     if (sensors_changed) {
       LowMemoryDetector::process_sensor_changes(jt);
     }
+
+    if(has_gc_notification_event) {
+        GCNotifier::sendNotification(CHECK);
+    }
   }
 }