public class ListenerGroup<T>
extends java.lang.Object
Constructor and Description |
---|
ListenerGroup(java.util.concurrent.ExecutorService executorService) |
Modifier and Type | Method and Description |
---|---|
EventDispatcher<T> |
add(T listener)
Adds the specified listener to the
ListenerGroup with the queue
limit set to DEFAULT_QUEUE_CAPACITY . |
EventDispatcher<T> |
add(T listener,
int queueCapacity)
Adds a listener to the
ListenerGroup . |
java.util.Collection<EventDispatcher<T>> |
addAll(java.util.Collection<T> listeners)
Adds all the specified listeners to the
ListenerGroup with the
queue capacity for each set to Integer.MAX_VALUE . |
java.util.Collection<EventDispatcher<T>> |
addAll(java.util.Collection<T> listeners,
int limit)
Adds all the specified listeners to the
ListenerGroup . |
void |
shutdown() |
void |
signal(SignalRunnable<T> signalRunnable)
Signals all listeners.
|
boolean |
signal(SignalRunnable<T> signalRunnable,
long timeout,
java.util.concurrent.TimeUnit unit)
Signals all listeners and waits for the result.
|
int |
size() |
public ListenerGroup(java.util.concurrent.ExecutorService executorService)
public EventDispatcher<T> add(T listener, int queueCapacity)
ListenerGroup
.listener
- the listener to addqueueCapacity
- the maximum number of events to bufferEventDispatcher
responsible for calling the specified
listenerpublic EventDispatcher<T> add(T listener)
ListenerGroup
with the queue
limit set to DEFAULT_QUEUE_CAPACITY
.listener
- the listener to addEventDispatcher
responsible for calling the specified
listenerpublic java.util.Collection<EventDispatcher<T>> addAll(java.util.Collection<T> listeners, int limit)
ListenerGroup
.listeners
- the listeners to addlimit
- the maximum number of events to bufferCollection
of EventDispatcher
s responsible for
calling the specified listenerspublic java.util.Collection<EventDispatcher<T>> addAll(java.util.Collection<T> listeners)
ListenerGroup
with the
queue capacity for each set to Integer.MAX_VALUE
.listeners
- the listeners to addCollection
of EventDispatcher
s responsible for
calling the specified listenerspublic int size()
public void signal(SignalRunnable<T> signalRunnable)
Each SignalRunnable
is executed in a separate thread.
public boolean signal(SignalRunnable<T> signalRunnable, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Each SignalRunnable
is executed in a separate thread. In the event
that the SignalRunnable
is be dropped from the
EventDispatcher
's queue and thus not executed, this method will
block for the entire specified timeout.
true
if all listeners completed within the specified time
limit, false
otherwisejava.lang.InterruptedException
public void shutdown()