Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4193

avoid synchronization blocks with ConcurrentLinkedQueue

XMLWordPrintable

    • ZK 8.6.3 S1
    • None

      currently _schedInfos in DesktopImpl is manually synchronized

      https://github.com/zkoss/zk/blob/v8.6.0.1/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java#L163-L164

      Using a ConcurrentLinkedQueue (since java 1.5) can avoid synchronized blocks when adding ScheduleListeners to the end (.offer()) ...
      https://github.com/zkoss/zk/blob/v8.6.0.1/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java#L1597-L1603

      and removing them from the start of the queue (.poll()).
      https://github.com/zkoss/zk/blob/v8.6.0.1/zk/src/org/zkoss/zk/ui/impl/DesktopImpl.java#L1802-L1825

      At the same time the loop code can be simplified (no need to copy the contents, or re-add intermediately added items)

            DevChu DevChu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: