Class ConcurrentListenerManager<L>

All Implemented Interfaces:

public class ConcurrentListenerManager<L> extends Object implements AutoCloseable
Provides per-listener event queues, and fires off events concurrently across listeners, but in-order per listener.
  • Constructor Details

    • ConcurrentListenerManager

      public ConcurrentListenerManager()
  • Method Details

    • close

      public void close()
      When no longer needed, close should be called to free resources.
      Specified by:
      close in interface AutoCloseable
    • addListener

      public void addListener(L listener, boolean synchronous) throws IllegalStateException
      Adds a listener.
      synchronous - When true, listener will be called synchronously by the I/O thread; when false, listener will be called asynchronously by a separate thread.
      IllegalStateException - If the listener has already been added
    • removeListener

      public boolean removeListener(L listener)
      Removes a listener.
      true if the listener was found
    • enqueueEvent

      public Future<?> enqueueEvent(ConcurrentListenerManager.Event<? super L> event)
      Enqueues a new event to all listener event queues. If the caller needs to wait until the event has been handled by each of the listeners, then call .get() on the returned Future.