Uploaded image for project: 'Avalon Merlin Runtime'
  1. Avalon Merlin Runtime
  2. RUNTIME-51

SimpleFIFO in Merlin implementation wastes CPU cycles

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.4.0
    • None
    • CORE
    • None

    Description

      The class SimpleFifo in the Merlin implementation wastes CPU cycles every 100 ms. The method get verify if the queue is no longer empty every 100 ms instead of waiting to be notified when a new element is added to the queue. Also, the put method notifies all waiting threads instead of notifying only one thread. It is not necessary to notify all threads because if many threads are waiting, then only one can get the newly added element.

      The following file must be updated: trunk\runtime\merlin\impl\src\java\org\apache\avalon\merlin\impl\SimpleFIFO.java

      Apply the following patch:

      // -----BEGIN PATCH
      Index: SimpleFIFO.java
      ===================================================================
      — SimpleFIFO.java (revision 36413)
      +++ SimpleFIFO.java (working copy)
      @@ -42,7 +42,7 @@
      synchronized( this )

      { m_Queue.add( obj ); - notifyAll(); + notify(); }

      }

      @@ -52,7 +52,7 @@
      synchronized( this )

      { while( m_Queue.size() == 0 ) - wait(100); + wait(); return m_Queue.remove(0); }

      }
      // -----END PATCH

      Attachments

        Activity

          People

            mcconnell Stephen McConnell
            carelparadis Carel Paradis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: