Class ThreadSafeListenableImpl<ListenerT>

  • Type Parameters:
    ListenerT - Type of listener.
    All Implemented Interfaces:
    Listenable<ListenerT>

    public class ThreadSafeListenableImpl<ListenerT>
    extends java.lang.Object
    implements Listenable<ListenerT>

    This class is for internal use only. Users must not rely on it.

    Thread safe container for listeners. Relies on double-dispatch via visitors instead of using event objects.

    Since:
    7.0
    • Constructor Detail

      • ThreadSafeListenableImpl

        public ThreadSafeListenableImpl()
    • Method Detail

      • removeListener

        public ListenerT removeListener​(ListenerT listener)
        Unregister listener. Due to implementation specifics, the listener may get notified a few more times after it is unregistered. It is guaranteed that the listener will not get notified after it is removed, if you have only one notification thread ( visitListeners(ThrowingVisitor) is called always by the same thread) and removal happens on that notification thread.
        Specified by:
        removeListener in interface Listenable<ListenerT>
        Parameters:
        listener - Registered listener.
        Returns:
        the actual listener being registered. This is useful when the passed in instance is only used for identification and the actual listener needs to be properly disposed of.
      • visitListeners

        public void visitListeners​(ThreadSafeListenableImpl.ThrowingVisitor<ListenerT> visitor)
                            throws java.lang.Exception
        Visit registered listeners with the specified visitor.
        Parameters:
        visitor - Visitor.
        Throws:
        java.lang.Exception - Error thrown by the visitor.