org.eidola.kernel.event
Class EventQueue
java.lang.Object
|
+--java.lang.Thread
|
+--org.eidola.kernel.event.EventQueue
- All Implemented Interfaces:
- Runnable
- public class EventQueue
- extends Thread
- implements Runnable
A queue dispatches Event
s to EventListener
s. Typically,
a single queue is associated with a listener or a collection of listeners
with a single purpose -- i.e. compiling elements or updating a view.
There are two common ways of running an event queue:
- As a single thread:
EventQueue q = new EventQueue("test");
q.start();
- Using multiple threads using
ThreadFlock
:
EventQueue q = new EventQueue("test");
ThreadFlock flock = new ThreadFlock(q, 4);
flock.start();
- Version:
- [Development version]
- Author:
- Paul Cantrell
- See Also:
Event
,
EventBroadcaster
,
EventListener
Method Summary |
void |
addEvent(Event event,
EventListener target)
Adds an event to the queue. |
boolean |
isEmpty()
Determines whether this queue is empty. |
void |
run()
Consumes and handles events from this queue. |
String |
toString()
For debugging -- returns this queue's name. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
name
public String name
- For debugging.
debug
public static boolean debug
EventQueue
public EventQueue(String name)
- Constructs a new empty queue.
- Parameters:
name
- For debugging.
toString
public String toString()
- For debugging -- returns this queue's name.
- Overrides:
toString
in class Thread
isEmpty
public boolean isEmpty()
- Determines whether this queue is empty.
addEvent
public void addEvent(Event event,
EventListener target)
- Adds an event to the queue. Typically, you will not call this directly;
that's really the job of
EventBroadcaster.broadcastEvent(Event)
.
run
public void run()
- Consumes and handles events from this queue. Typically, you will not call this
method directly, but rather call
Thread.start()
.
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread