Package jmri.util
Class PropertyChangeEventQueue
java.lang.Object
jmri.util.PropertyChangeEventQueue
@ThreadSafe public class PropertyChangeEventQueue extends 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) BlockingQueue<PropertyChangeEvent>
dq
(package private) Collection<NamedBean>
items
(package private) PropertyChangeListener
listener
(package private) static int
MAX_SIZE
-
Constructor Summary
Constructors Constructor Description PropertyChangeEventQueue(Collection<NamedBean> collection)
PropertyChangeEventQueue(NamedBean[] array)
-
Method Summary
Modifier and Type Method Description void
dispose()
Dispose by dropping the listeners to all the specifiedNamedBean
s.PropertyChangeEvent
poll(long timeout, TimeUnit unit)
PropertyChangeEvent
take()
String
toString()
-
Field Details
-
items
-
MAX_SIZE
- See Also:
- Constant Field Values
-
dq
-
listener
-
-
Constructor Details
-
PropertyChangeEventQueue
- Parameters:
collection
- Set of NamedBeans whose events should be handled. Keeps a copy of the contents, so future changes irrelevant.
-
PropertyChangeEventQueue
- Parameters:
array
- Set of NamedBeans whose events should be handled Keeps a copy of the contents, so future changes irrelevant.
-
-
Method Details
-
dispose
Dispose by dropping the listeners to all the specifiedNamedBean
s. The object should not be used again after calling this. It is not an error to call this multiple times. -
take
- Throws:
InterruptedException
-
poll
- Throws:
InterruptedException
-
toString
-