|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ros.concurrent.ListenerCollection<T>
public class ListenerCollection<T>
Manages a collection of listeners and makes it easy to execute a listener callback on the entire collection.
Nested Class Summary | |
---|---|
static interface |
ListenerCollection.SignalRunnable<U>
|
Constructor Summary | |
---|---|
ListenerCollection(java.util.Collection<T> listeners,
java.util.concurrent.ExecutorService executorService)
|
|
ListenerCollection(java.util.concurrent.ExecutorService executorService)
|
Method Summary | |
---|---|
void |
add(T listener)
|
void |
addAll(java.util.Collection<T> listeners)
|
void |
clear()
Removes all listeners from the collection. |
boolean |
remove(T listener)
|
void |
signal(ListenerCollection.SignalRunnable<T> signalRunnable)
Signal all listeners. |
void |
signal(ListenerCollection.SignalRunnable<T> signalRunnable,
long timeout,
java.util.concurrent.TimeUnit unit)
Signal all listeners and wait for the all ListenerCollection.SignalRunnable s to
return. |
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListenerCollection(java.util.concurrent.ExecutorService executorService)
executorService
- the ScheduledExecutorService
to use when executing
listener callbackspublic ListenerCollection(java.util.Collection<T> listeners, java.util.concurrent.ExecutorService executorService)
listeners
- an initial Collection
of listeners to addexecutorService
- the ExecutorService
to use when executing listener
callbacksMethod Detail |
---|
public void add(T listener)
listener
- the listener to addpublic void addAll(java.util.Collection<T> listeners)
listeners
- a Collection
of listeners to addpublic boolean remove(T listener)
listener
- the listener to remove
true
if the listener was removed, false
otherwisepublic void clear()
public int size()
public void signal(ListenerCollection.SignalRunnable<T> signalRunnable)
Each ListenerCollection.SignalRunnable
is executed in a separate thread.
public void signal(ListenerCollection.SignalRunnable<T> signalRunnable, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
ListenerCollection.SignalRunnable
s to
return.
Each ListenerCollection.SignalRunnable
is executed in a separate thread.
java.lang.InterruptedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |