public interface Actor
Actors are objects which send messages to each other and which process only one message at a time. Messages are either requests or responses. When an actor sends a request to another actor, it expects to receive a single response unless an exception has been thrown.
When an actor sends a message it provides a callback to handle the response. The callback may be invoked either immediately or later. After sending a message, an actor may send additional messages or return control, at which point it may receive other requests or pending responses.
An actor typically interleaves the processing of multiple requests. To process a request to completion, an actor may need to send requests to other actors (in series or parallel) and process the responses to those requests. Actors process requests and responses as they are received whenever the actor is not busy processing a message. There is no way to block incoming requests. Actors are thread-safe, but message processing is not atomic.
Some actors are asynchronous. Requests sent to an asynchronous actor are processed on a different thread. Actors which perform heavy computation or which do I/O should be asynchronous. Asynchronous actors play an important role in vertical scalability, allowing a program to make effective use of multiple hardware threads. But care should be used, as asynchronous message passing tends to be slow.
Modifier and Type | Method and Description |
---|---|
void |
acceptEvent(APCRequestSource requestSource,
Request request)
Wraps and enqueues an unwrapped request in the requester's inbox.
|
void |
acceptRequest(APCRequestSource requestSource,
Request request,
RP rp)
Wraps and enqueues an unwrapped request in the requester's inbox.
|
String |
getActorType()
Returns the actor type.
|
JLPCActor |
getAncestor(Class targetClass)
Returns A matching ancestor from the parent chain.
|
ActorFactory |
getFactory()
Returns the factory.
|
Mailbox |
getMailbox()
Returns the actor's mailbox.
|
JLPCActor |
getMatch(Class targetClass) |
JLPCActor |
getParent()
Returns the actor's parent.
|
boolean |
hasDataItem(String name)
Returns true when the concurrent data of the actor, or its parent, contains the named data item.
|
void |
setInitialBufferCapacity(int initialBufferCapacity)
Set the initial capacity for buffered outgoing messages.
|
void acceptRequest(APCRequestSource requestSource, Request request, RP rp) throws Exception
requestSource
- The originator of the request.request
- The unwrapped request to be sent.rp
- The request processor.Exception
void acceptEvent(APCRequestSource requestSource, Request request) throws Exception
requestSource
- The originator of the request.request
- The unwrapped request to be sent.Exception
void setInitialBufferCapacity(int initialBufferCapacity)
initialBufferCapacity
- The initial capacity for buffered outgoing messages.boolean hasDataItem(String name)
name
- The key for the data item.Mailbox getMailbox()
String getActorType()
ActorFactory getFactory()
JLPCActor getParent()
JLPCActor getAncestor(Class targetClass)
targetClass
- A class which the ancestor is an instanceof.Copyright © 2012. All Rights Reserved.