net.eduvax.util
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.LinkedBlockingQueue<T> |
_fifo
Event queue, as far as T type is an event.
|
private HandlerList<T> |
_handlers
HandlerList containing hub member handlers
|
private java.lang.String |
_name
hub name
|
private T |
_stopObject
object to insert to order Hub shutdown
|
Constructor and Description |
---|
Hub(java.lang.String name)
create new hub
|
Modifier and Type | Method and Description |
---|---|
void |
add(Handler<T> handler)
register handler
|
void |
handle(T obj)
Handling object by hub is enqueuing it.
|
void |
remove(Handler<T> handler)
deregister handler
|
void |
run() |
void |
setStopObject(T stop)
Defines obj to use as stop signal when found in queue.
|
void |
start()
Start hub with its own thread
|
void |
stop()
Request Hub shutdown.
|
private HandlerList<T> _handlers
private java.util.concurrent.LinkedBlockingQueue<T> _fifo
private java.lang.String _name
private T _stopObject
public void start()
public void handle(T obj)
public void setStopObject(T stop)
public void add(Handler<T> handler)
handler
- handler to register to this hubpublic void remove(Handler<T> handler)
handler
- handler to remove from this hubpublic void stop()
public void run()
run
in interface java.lang.Runnable