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 boolean
addHandler(EventHandler<Event> handler)
Adds anEventHandler
that will be notified of every event sent to this actor.void
notify(Event event)
Sends an event to the actor, which will be delivered to all registered event handlers.boolean
removeHandler(EventHandler<Event> handler)
Removes anEventHandler
from the actorjava.lang.String
toString()
-
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 anEventHandler
that will be notified of every event sent to this actor.- Parameters:
handler
- the handler- Returns:
true
if the handler has been successfully added to the actor, orfalse
if the handler was already registered.- Throws:
SuspendExecution
java.lang.InterruptedException
-
removeHandler
public boolean removeHandler(EventHandler<Event> handler) throws SuspendExecution, java.lang.InterruptedException
Removes anEventHandler
from the actor- Parameters:
handler
-- Returns:
true
if the handler was registered and successfully removed, orfalse
if the handler was not registered.- Throws:
SuspendExecution
java.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
-
-