Class EventSource<Event>
- java.lang.Object
-
- co.paralleluniverse.actors.ActorRef<Message>
-
- co.paralleluniverse.actors.ActorRefDelegate<java.lang.Object>
-
- co.paralleluniverse.actors.behaviors.Behavior
-
- co.paralleluniverse.actors.behaviors.EventSource<Event>
-
- All Implemented Interfaces:
Port<java.lang.Object>,PortAutoCloseable,SendPort<java.lang.Object>,java.io.Serializable,java.lang.AutoCloseable
public class EventSource<Event> extends Behavior
An interface to anEventSourceActor.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddHandler(EventHandler<Event> handler)Adds anEventHandlerthat will be notified of every event sent to this actor.voidnotify(Event event)Sends an event to the actor, which will be delivered to all registered event handlers.booleanremoveHandler(EventHandler<Event> handler)Removes anEventHandlerfrom the actorjava.lang.StringtoString()-
Methods inherited from class co.paralleluniverse.actors.ActorRefDelegate
getImpl, isInActor
-
Methods inherited from class co.paralleluniverse.actors.ActorRef
close, close, equals, getName, hashCode, interrupt, send, send, send, sendSync, trySend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface co.paralleluniverse.strands.channels.PortAutoCloseable
isClosed
-
-
-
-
Method Detail
-
addHandler
public boolean addHandler(EventHandler<Event> handler) throws SuspendExecution, java.lang.InterruptedException
Adds anEventHandlerthat will be notified of every event sent to this actor.- Parameters:
handler- the handler- Returns:
trueif the handler has been successfully added to the actor, orfalseif the handler was already registered.- Throws:
SuspendExecutionjava.lang.InterruptedException
-
removeHandler
public boolean removeHandler(EventHandler<Event> handler) throws SuspendExecution, java.lang.InterruptedException
Removes anEventHandlerfrom the actor- Parameters:
handler-- Returns:
trueif the handler was registered and successfully removed, orfalseif the handler was not registered.- Throws:
SuspendExecutionjava.lang.InterruptedException
-
notify
public void notify(Event event) throws SuspendExecution
Sends an event to the actor, which will be delivered to all registered event handlers.- Parameters:
event- the event- Throws:
SuspendExecution
-
-