|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.vub.at.actors.eventloops.EventLoop
The EventLoop is the basic concurrency primitive for the AmbientTalk/2 implementation. An Event Loop consists of an event queue, an event processing thread and an event handler. The event loop's thread perpetually takes the next event from the event queue and makes the event loop process it. Hence, the event loop is the event handler in this architecture. Event Loops form the reusable core of both actors, remote references and even the virtual machine itself (i.e. it is the core of both programmer-defined and native actors). This is an abstract class. To be usable, subclasses have to provide a meaningful implemementation strategy for handling events by overriding the handle method.
Nested Class Summary | |
class |
EventLoop.EventProcessor
EventProcessor is a thread subclass whose primary goal is to keep a reference to the associated event loop, which is used to transform threads into the more manageable event loops |
Field Summary | |
private boolean |
askedToStop_
|
protected EventQueue |
eventQueue_
The event loop's event queue is a synchronized queue of Event objects. |
private java.lang.String |
name_
|
protected java.lang.Thread |
processor_
Each event loop has an event processor, which is a thread responsible for perpetually dequeuing events from the event queue and passing them on to this event loop's handle method. |
Constructor Summary | |
EventLoop(java.lang.String name)
Constructos a new event loop with the default processing behaviour. |
Method Summary | |
static EventLoop |
currentEventLoop()
Allows access to the currently running event loop. |
void |
execute()
|
abstract void |
handle(Event event)
Subclasses are responsible for defining a meaningful implementation strategy to handle events from the event queue. |
protected EventLoop |
owner()
|
protected void |
receive(Event event)
When an event loop receives an asynchronously emitted event, this message is immediately placed into its incoming event queue and will be processed later. |
protected java.lang.Object |
receiveAndWait(java.lang.String description,
Callable callable)
Schedules an event in this event loop's queue which will execute the provided callable object at a later point in time. |
protected void |
receivePrioritized(Event event)
When an event loop receives an asynchronously emitted event, this message is immediately placed into its incoming event queue and will be processed later. |
void |
stopProcessing()
|
static EventLoop |
toEventLoop(java.lang.Thread t)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final EventQueue eventQueue_
protected java.lang.Thread processor_
private boolean askedToStop_
private final java.lang.String name_
Constructor Detail |
public EventLoop(java.lang.String name)
name
- used for debugging purposesMethod Detail |
public java.lang.String toString()
public static EventLoop toEventLoop(java.lang.Thread t) throws java.lang.IllegalStateException
java.lang.IllegalStateException
public static EventLoop currentEventLoop() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the current thread is not the thread of an event looppublic final void stopProcessing()
protected final void receive(Event event)
protected final java.lang.Object receiveAndWait(java.lang.String description, Callable callable) throws java.lang.Exception
description
- a description of the task being scheduled, for debugging purposescallable
- the functor object encapsulating the task to be performed inside the event loop
java.lang.Exception
protected final void receivePrioritized(Event event)
public abstract void handle(Event event)
event
- the event object which was dequeued and which should be processedprotected final EventLoop owner()
public void execute()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |