Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090999

Avoid copying of pulse listener lists in Toolkit

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • tbd
    • 8
    • javafx

    Description

      We could use copy-on-write approach instead of copying on every pulse;

      This means, in synchronized block, we'd set some flag:
      synchronized(this) {
         stagePulseListInUse = scenePulseListInUse = postScenePulseListInUse = true;
      }

      and unset them at the end of the pulse.

      Then instead of full copies, do just reference copy:
      final Map<TKPulseListener,AccessControlContext> stagePulseList = stagePulseListeners;
      ...

      The add*Listener methods would look like:
       
      synchronized(this) {
          AccessControlContext acc = AccessController.getContext();
          if (stagePulseListInUse) {
              stagePulseListInUse = false;
              stagePulseListeners = new WeakHashMap<>(stagePulseListeners);
          }
          stagePulseListeners.add(listener);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            msladecek Martin Sládeček
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Imported: