Package jmri.util

Class PropertyChangeEventQueue


  • @ThreadSafe
    public class PropertyChangeEventQueue
    extends java.lang.Object
    Gathers PropertyChangeEvents that might occur in overlapping threads and at overlapping times, presenting them as requested.

    Listeners are installed when the object is constructed. dispose() detaches those listeners, after which the object should not be used. It is not an error to call dispose() multiple times.

    Although this could be more generic than NamedBean, there's no single interface that specifies "can call addPropertyChangeListener(..)".

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.concurrent.BlockingQueue<java.beans.PropertyChangeEvent> dq  
      (package private) java.util.Collection<NamedBean> items  
      (package private) java.beans.PropertyChangeListener listener  
      (package private) static int MAX_SIZE  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      Dispose by dropping the listeners to all the specified NamedBeans.
      java.beans.PropertyChangeEvent poll​(long timeout, java.util.concurrent.TimeUnit unit)  
      java.beans.PropertyChangeEvent take()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PropertyChangeEventQueue

        public PropertyChangeEventQueue​(@Nonnull
                                        java.util.Collection<NamedBean> collection)
        Parameters:
        collection - Set of NamedBeans whose events should be handled. Keeps a copy of the contents, so future changes irrelevant.
      • PropertyChangeEventQueue

        public PropertyChangeEventQueue​(@Nonnull
                                        NamedBean[] array)
        Parameters:
        array - Set of NamedBeans whose events should be handled Keeps a copy of the contents, so future changes irrelevant.
    • Method Detail

      • dispose

        public void dispose()
        Dispose by dropping the listeners to all the specified NamedBeans. The object should not be used again after calling this. It is not an error to call this multiple times.
      • take

        public java.beans.PropertyChangeEvent take()
                                            throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • poll

        public java.beans.PropertyChangeEvent poll​(long timeout,
                                                   java.util.concurrent.TimeUnit unit)
                                            throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object