Top


定義場所(file name)

hotspot/src/share/vm/prims/jvmtiImpl.cpp

説明(description)

// This method transfers any events that were added by someone NOT holding
// the lock into the mainline queue.

名前(function name)

void JvmtiDeferredEventQueue::process_pending_events() {

本体部(body)

  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}

      assert(Service_lock->owned_by_self(), "Must own Service_lock");

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

      if (_pending_list != NULL) {
        QueueNode* head =
            (QueueNode*)Atomic::xchg_ptr(NULL, (volatile void*)&_pending_list);

        assert((_queue_head == NULL) == (_queue_tail == NULL),
               "Inconsistent queue markers");

        if (head != NULL) {
          // Since we've treated the pending list as a stack (with newer
          // events at the beginning), we need to join the bottom of the stack
          // with the 'tail' of the queue in order to get the events in the
          // right order.  We do this by reversing the pending list and appending
          // it to the queue.

          QueueNode* new_tail = head;
          QueueNode* new_head = NULL;

          // This reverses the list
          QueueNode* prev = new_tail;
          QueueNode* node = new_tail->next();
          new_tail->set_next(NULL);
          while (node != NULL) {
            QueueNode* next = node->next();
            node->set_next(prev);
            prev = node;
            node = next;
          }
          new_head = prev;

          // Now append the new list to the queue
          if (_queue_tail != NULL) {
            _queue_tail->set_next(new_head);
          } else { // _queue_head == NULL
            _queue_head = new_head;
          }
          _queue_tail = new_tail;
        }
      }
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.