| java.lang.Object edu.rice.cs.drjava.model.EventNotifier
EventNotifier | abstract public class EventNotifier (Code) | | Base class for all component-specific EventNotifiers. This class provides common methods to
manage listeners of a specific type. T the type of the listener class to be managed.
version: $Id: EventNotifier.java 4268 2007-11-29 00:52:17Z mgricken $ |
Field Summary | |
final protected LinkedList<T> | _listeners All T Listeners that are listening to the model. | final protected ReaderWriterLock | _lock Provides synchronization primitives for solving the readers/writers problem. |
Method Summary | |
public void | addListener(T listener) Adds a listener to the notifier. | public void | removeAllListeners() Removes all listeners from this notifier. | public void | removeListener(T listener) Removes a listener from the notifier. |
_listeners | final protected LinkedList<T> _listeners(Code) | | All T Listeners that are listening to the model. Accesses to this collection are protected by the
ReaderWriterLock. The collection must be synchronized, since multiple readers could access it at once.
|
_lock | final protected ReaderWriterLock _lock(Code) | | Provides synchronization primitives for solving the readers/writers problem. In EventNotifier, adding and
removing listeners are considered write operations, and all notifications are considered read operations. Multiple
reads can occur simultaneously, but only one write can occur at a time, and no reads can occur during a write.
|
addListener | public void addListener(T listener)(Code) | | Adds a listener to the notifier.
Parameters: listener - a listener that reacts on events |
removeAllListeners | public void removeAllListeners()(Code) | | Removes all listeners from this notifier. If the thread already holds the lock,
then the listener is removed later, but as soon as possible.
Note: It is NOT guaranteed that the listener will not be executed again.
|
removeListener | public void removeListener(T listener)(Code) | | Removes a listener from the notifier. If the thread already holds the lock,
then the listener is removed later, but as soon as possible.
Note: It is NOT guaranteed that the listener will not be executed again.
Parameters: listener - a listener that reacts on events |
|
|